Articles on Trending Technologies

Technical articles with clear explanations and examples

How can a specific operation be applied row wise or column wise in Pandas Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 551 Views

In Pandas, you can apply operations to a DataFrame either row-wise or column-wise using the apply() function. By default, operations are applied column-wise (axis=0), but you can specify the axis parameter to control the direction. Column-wise Operations (Default) When no axis is specified, operations are applied to each column ? import pandas as pd import numpy as np my_data = {'Age': pd.Series([45, 67, 89, 12, 23]), 'value': pd.Series([8.79, 23.24, 31.98, 78.56, 90.20])} my_df = pd.DataFrame(my_data) print("The dataframe is:") print(my_df) print("Column-wise mean:") print(my_df.apply(np.mean)) ...

Read More

How can data be summarized in Pandas Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 254 Views

Pandas provides powerful methods to summarize and get statistical insights from your data. The most comprehensive function for data summarization is describe(), which generates descriptive statistics for numerical columns. The describe() function provides key statistics including count, mean, standard deviation, minimum value, and quartiles (25th, 50th, and 75th percentiles). Syntax DataFrame.describe(percentiles=None, include=None, exclude=None) Basic Data Summarization Here's how to use describe() to get a complete statistical summary ? import pandas as pd # Create sample data data = { 'Name': pd.Series(['Tom', 'Jane', 'Vin', 'Eve', 'Will']), ...

Read More

How to find the standard deviation of specific columns in a dataframe in Pandas Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 7K+ Views

Standard deviation measures how spread out values are in a dataset and indicates how far individual values are from the arithmetic mean. In Pandas, you can calculate the standard deviation of specific columns using the std() function. When working with DataFrames, you often need to find the standard deviation of particular numeric columns. The std() function can be applied to individual columns by indexing the DataFrame with the column name. Example Let's create a DataFrame and calculate the standard deviation of specific columns ? import pandas as pd my_data = { ...

Read More

How can decision tree be used to construct a classifier in Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 306 Views

Decision trees are one of the most intuitive and widely-used algorithms in machine learning for classification tasks. They work by recursively splitting the dataset based on feature values to create a tree-like model that makes predictions by following decision paths from root to leaf nodes. How Decision Trees Work A decision tree splits the input space into regions based on feature values. Each internal node represents a decision based on a feature, while leaf nodes contain the final prediction. The algorithm uses measures like Gini impurity to determine the best splits that maximize information gain. The tree ...

Read More

How to view the pixel values of an image using scikit-learn in Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 879 Views

Viewing pixel values of an image is a fundamental step in image processing and computer vision tasks. Scikit-image provides convenient functions to read images and extract pixel data, which can then be converted to a pandas DataFrame for analysis. Images are stored as multi-dimensional arrays where each pixel has intensity values. For RGB images, each pixel contains three values (Red, Green, Blue), while grayscale images have single intensity values per pixel. Reading and Displaying an Image First, let's read an image and display its basic properties ? from skimage import io, data import pandas as ...

Read More

How can scikit-learn library be used to get the resolution of an image in Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 560 Views

Data pre-processing refers to the task of gathering data from various resources into a common format. Since real-world data is never ideal, images may have alignment issues, clarity problems, or incorrect sizing. The goal of pre-processing is to remove these discrepancies. To get the resolution of an image, we use the shape attribute. After reading an image, pixel values are stored as a NumPy array. The shape attribute returns the dimensions of this array, representing the image resolution. Reading and Getting Image Resolution Let's see how to upload an image and get its resolution using scikit-image library ...

Read More

How to get the mean of columns that contains numeric values of a dataframe in Pandas Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 1K+ Views

Sometimes, you may need to calculate the mean values of specific columns or all columns containing numeric data in a pandas DataFrame. The mean() function automatically identifies and computes the mean for numeric columns only. The term mean refers to finding the sum of all values and dividing it by the total number of values in the dataset (also called the arithmetic average). Basic Example Let's create a DataFrame with mixed data types and calculate the mean of numeric columns − import pandas as pd # Create a DataFrame with mixed data types data ...

Read More

How to get the sum of a specific column of a dataframe in Pandas Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 1K+ Views

Sometimes, it may be required to get the sum of a specific column in a Pandas DataFrame. This is where the sum() function can be used to perform column-wise calculations. The column whose sum needs to be computed can be accessed by column name or index. Let's explore different approaches to calculate the sum of a specific column. Creating a Sample DataFrame First, let's create a DataFrame with sample data ? import pandas as pd my_data = { 'Name': pd.Series(['Tom', 'Jane', 'Vin', 'Eve', 'Will']), 'Age': pd.Series([45, ...

Read More

How to delete a column of a dataframe using the 'pop' function in Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 410 Views

A Pandas DataFrame is a two-dimensional data structure where data is stored in tabular format with rows and columns. It can be visualized as an SQL table or Excel sheet. The pop() function provides an efficient way to delete a column while simultaneously returning its values. Syntax DataFrame.pop(item) Parameters: item − The column name to be removed Returns: The removed column as a Series Example Let's create a DataFrame and delete a column using the pop() function ? import pandas as pd my_data = { ...

Read More

How can a column of a dataframe be deleted in Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 253 Views

A DataFrame is a two-dimensional data structure where data is stored in tabular format with rows and columns. It can be visualized as an SQL table or Excel sheet. There are several methods to delete columns from a DataFrame in Python pandas. Using the del Operator The del operator permanently removes a column from the DataFrame ? import pandas as pd my_data = { 'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 30, 35], 'City': ['New York', 'London', 'Paris'], 'Salary': [50000, ...

Read More
Showing 5941–5950 of 61,299 articles
« Prev 1 593 594 595 596 597 6130 Next »
Advertisements