Python Articles

Page 148 of 855

What is digital certificate and digital signature?

Bhanu Priya
Bhanu Priya
Updated on 26-Mar-2026 5K+ Views

Digital certificates and digital signatures are fundamental concepts in cybersecurity that ensure secure communication and data integrity. Let's explore both concepts and understand how they work together to provide authentication and security. Digital Certificate A digital certificate is an electronic document issued by a trusted Certificate Authority (CA) that verifies the identity of an individual, organization, or device. It contains the entity's public key and identifying information, digitally signed by the CA to guarantee authenticity. Components of a Digital Certificate A digital certificate typically contains ? Subject's public key − Used for encryption and ...

Read More

Python Pandas - Finding the uncommon rows between two DataFrames

AmitDiwan
AmitDiwan
Updated on 26-Mar-2026 3K+ Views

To find the uncommon rows between two DataFrames, you can use concat() combined with drop_duplicates(). This approach concatenates both DataFrames and removes duplicate rows, leaving only the uncommon ones. Syntax pd.concat([df1, df2]).drop_duplicates(keep=False) Where keep=False removes all occurrences of duplicated rows, leaving only the unique rows from each DataFrame. Example Let's create two DataFrames with car data and find the uncommon rows ? import pandas as pd # Create DataFrame1 dataFrame1 = pd.DataFrame({ "Car": ['BMW', 'Lexus', 'Audi', 'Tesla', 'Bentley', 'Jaguar'], "Reg_Price": [1000, 1500, ...

Read More

How to shift a column in a Pandas DataFrame?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 8K+ Views

The shift() method in Pandas allows you to shift the values in a column up or down by a specified number of positions. This is useful for creating lagged variables or aligning time series data. Syntax shift(periods=1, freq=None, axis=0, fill_value=None) Parameters periods − Number of positions to shift. Positive values shift down, negative values shift up. axis − 0 for shifting along rows (default), 1 for shifting along columns. fill_value − Value to use for filling the newly created missing positions. Basic Column Shifting Let's create a DataFrame and demonstrate ...

Read More

How to append two DataFrames in Pandas?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 88K+ Views

To append the rows of one DataFrame with the rows of another, we can use the Pandas append() function. With the help of append(), we can combine DataFrames vertically. Let's see how to use this method with examples. Note: The append() method is deprecated since Pandas 1.4.0. Use pd.concat() instead for new code. Steps to Append DataFrames Create two DataFrames with data Use append() method or pd.concat() to combine them Set ignore_index=True to reset row indices Handle different column names appropriately Example 1: Appending DataFrames with Same Columns When DataFrames have the same ...

Read More

How to get nth row in a Pandas DataFrame?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 43K+ Views

To get the nth row in a Pandas DataFrame, we can use the iloc[] method. For example, df.iloc[4] will return the 5th row because row numbers start from 0. Syntax df.iloc[n] Where n is the index position (0-based) of the row you want to access. Creating a Sample DataFrame Let's create a DataFrame with student information ? import pandas as pd df = pd.DataFrame({ 'name': ['John', 'Jacob', 'Tom', 'Tim', 'Ally'], 'marks': [89, 23, 100, 56, 90], 'subjects': ["Math", ...

Read More

How to find numeric columns in Pandas?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 7K+ Views

To find numeric columns in Pandas, we can use the select_dtypes() method to filter columns based on their data types. This method allows us to specify which numeric types to include or exclude from our DataFrame. Basic Example Let's start with a simple example using select_dtypes() ? import pandas as pd # Create a DataFrame with mixed data types df = pd.DataFrame({ 'name': ['John', 'Jacob', 'Tom', 'Tim', 'Ally'], 'marks': [89, 23, 100, 56, 90], 'subjects': ["Math", "Physics", "Chemistry", "Biology", "English"] }) print("Input ...

Read More

Python Pandas – Find the maximum value of a column and return its corresponding row values

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 30K+ Views

To find the maximum value of a column and return its corresponding row values in Pandas, we can use df.loc[df[col].idxmax()]. This method first finds the index of the maximum value using idxmax(), then uses loc[] to retrieve the entire row. Syntax df.loc[df[column_name].idxmax()] Where: df − The DataFrame column_name − The column to find the maximum value in idxmax() − Returns the index of the maximum value loc[] − Selects the row by index Example Let's create a DataFrame and find the maximum values for different columns ? import pandas ...

Read More

How to get the correlation between two columns in Pandas?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 33K+ Views

We can use the .corr() method to get the correlation between two columns in Pandas. The correlation coefficient measures the linear relationship between two variables, ranging from -1 to 1. Basic Syntax # Method 1: Using .corr() on a Series correlation = df['column1'].corr(df['column2']) # Method 2: Using .corr() on DataFrame to get correlation matrix correlation_matrix = df[['column1', 'column2']].corr() Example Let's create a DataFrame and calculate correlations between different columns ? import pandas as pd # Create sample DataFrame df = pd.DataFrame({ "x": [5, 2, 7, 0], ...

Read More

How to filter rows in Pandas by regex?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 18K+ Views

A regular expression (regex) is a sequence of characters that define a search pattern. Pandas provides several methods to filter DataFrame rows using regex patterns, including str.match(), str.contains(), and str.extract(). Using str.match() Method The str.match() method matches regex patterns from the beginning of each string ? import pandas as pd df = pd.DataFrame({ 'name': ['John', 'Jacob', 'Tom', 'Tim', 'Ally'], 'marks': [89, 23, 100, 56, 90], 'subjects': ["Math", "Physics", "Chemistry", "Biology", "English"] }) print("Input DataFrame:") print(df) Input DataFrame: ...

Read More

Python – Pandas Dataframe.rename()

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Mar-2026 4K+ Views

The rename() method in Pandas allows you to change column names in a DataFrame efficiently. You can rename single or multiple columns using dictionary mapping or functions. Basic Syntax The basic syntax for renaming columns is ? DataFrame.rename(columns={old_name: new_name}, inplace=False) Renaming a Single Column Here's how to rename one column using the rename() method ? import pandas as pd df = pd.DataFrame( { "x": [5, 2, 7, 0], "y": [4, ...

Read More
Showing 1471–1480 of 8,549 articles
« Prev 1 146 147 148 149 150 855 Next »
Advertisements