Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Server Side Programming Articles
Page 123 of 2109
Get the data type of column in Pandas - Python
Pandas is a popular and powerful Python library commonly used for data analysis and manipulation. It offers data structures like Series and DataFrame for working with tabular data. Each column in a Pandas DataFrame can contain a different data type. This article covers various methods for determining column data types in a DataFrame ? Sample DataFrame Let's create a sample DataFrame to demonstrate different approaches ? import pandas as pd # Create a sample dataframe df = pd.DataFrame({ 'Vehicle name': ['Supra', 'Honda', 'Lamborghini'], 'price': [5000000, 600000, ...
Read MoreGet tag name using Beautifulsoup in Python
BeautifulSoup is one of the most widely used Python packages for web scraping and parsing HTML and XML documents. One of the most common tasks when working with HTML and XML documents is extracting the tag name of specific elements. Python's BeautifulSoup library can be installed using the below command ? pip install beautifulsoup4 Using the name Attribute The most straightforward method to get tag names in BeautifulSoup is using the name attribute of the Tag object. This attribute returns a string value containing the name of the tag. Syntax tag.name ...
Read MoreGet specific row from PySpark dataframe
PySpark is a powerful tool for big data processing and analysis. When working with PySpark DataFrames, you often need to retrieve specific rows for analysis or debugging. This article explores various methods to get specific rows from PySpark DataFrames using functional programming approaches. Creating Sample DataFrame Let's create a sample DataFrame to demonstrate all the methods ? from pyspark.sql import SparkSession # Create SparkSession spark = SparkSession.builder.appName("get_specific_rows").getOrCreate() # Create sample DataFrame df = spark.createDataFrame([ ('Row1', 1, 2, 3), ('Row2', 4, 5, 6), ...
Read MoreEmotion classification using NRC Lexicon in Python
Emotion identification or recognition is the ability of a person or system to detect specific emotions from text and categorize them into distinct emotional categories. Unlike traditional sentiment analysis that only classifies text as positive or negative, emotion classification provides deeper insights into human emotions. Emotion Classification in Python using the NRC Lexicon offers a more nuanced approach than basic sentiment analysis. It can identify multiple emotions simultaneously and provides probability scores for each detected emotion. The NRC Emotion Lexicon, developed by the National Research Council of Canada, contains over 27, 000 terms mapped to emotions. It's based ...
Read MoreEmail + Social Logins in Django - Step-by-Step Guide
Email and social logins are essential authentication methods for modern web applications. Email login requires users to provide their email address and password, while social login allows users to authenticate using their existing accounts from platforms like Google or Facebook. In this tutorial, we'll implement both authentication methods in Django using the Django-allauth package. Installation First, install the django-allauth package using pip ? pip install django-allauth Project Setup Step 1: Configure Settings Add the required configurations to your settings.py file ? # settings.py INSTALLED_APPS = [ ...
Read MorePython program to find the smallest word in a sentence
Welcome to this tutorial on writing a Python program to find the smallest word in a sentence. Whether you are a beginner or intermediate Python programmer, this guide will help you learn text manipulation using Python's built-in functions. Problem Statement Given a sentence, we need to find the word with the fewest characters. In case of a tie, we'll return the first occurring smallest word. Using min() with key Parameter The most efficient approach uses the min() function with a key parameter to compare word lengths ? def find_smallest_word(sentence): # ...
Read MorePython Program to get the subarray from an array using a specified range of indices
An array is a homogeneous data structure used to store elements of the same data type. Each element is identified by a key or index value. Python provides several ways to extract subarrays from arrays using specified index ranges. What is a Subarray? A subarray is a continuous portion of elements from an array. For example, if we have an array: numbers = [9, 3, 1, 6, 9] print("Original array:", numbers) Original array: [9, 3, 1, 6, 9] The possible subarrays include: [9, 3] [9, 3, 1] [3, ...
Read MorePython Program to push an array into another array
In programming, an array is a data structure used to store a collection of homogeneous data elements. Each element is identified by an index value. Python doesn't have a specific array data type, so we use lists as arrays. Arrays in Python Here's how we represent a list as an array ? numbers = [1, 4, 6, 5, 3] print(numbers) [1, 4, 6, 5, 3] Python indexing starts from 0, so elements are accessed using index values 0, 1, 2, 3, 4. Pushing an array into another array means inserting ...
Read MorePython Program to convert an array into a string and join elements with a specified character
An array is a data structure consisting of a collection of elements of the same data type, where each element is identified by an index. In Python, we use lists to represent arrays and can convert them to strings with custom separators. Arrays in Python Python uses the list data structure to represent arrays. Here's an example of a list representing an array − numbers = [10, 4, 11, 76, 99] print(numbers) [10, 4, 11, 76, 99] Input Output Scenarios Let's see how array elements can be joined with specified ...
Read MorePython Program To Determine If a Given Matrix is a Sparse Matrix
A matrix is a rectangular array of numbers arranged in rows and columns. A sparse matrix is one that contains significantly more zero elements than non-zero elements − typically when more than half of the elements are zero. What is a Sparse Matrix? Consider this example matrix ? [0, 0, 3, 0, 0] [0, 1, 0, 0, 6] [1, 0, 0, 9, 0] [0, 0, 2, 0, 0] This 4×5 matrix has 20 total elements but only 6 non-zero values. Since 14 out of 20 elements are zero (70%), this qualifies as a sparse ...
Read More