The Ultimate Pandas Cheat Sheet for Data Professionals

Listen to this Post

Pandas is an essential tool for anyone working with data—whether you’re a Data Analyst, Scientist, or Machine Learning Engineer. This cheat sheet covers everything from basic operations to advanced techniques like groupby, merging, and time series analysis.

Key Topics Covered:

➡️ Revisiting the Basics – Data structures (Series, DataFrame), indexing, and selection.
➡️ Data Manipulation Challenges – Filtering, sorting, and handling missing data.
➡️ Cleaning & Transforming Data – String operations, datetime handling, and duplicate removal.
➡️ Advanced Operations – Merging, joining, pivoting, and aggregation.

You Should Know: Essential Pandas Commands & Examples

1. Basic DataFrame Operations

import pandas as pd

Create a DataFrame 
data = {'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 30, 35]} 
df = pd.DataFrame(data)

Display first few rows 
print(df.head())

Filter data 
filtered_df = df[df['Age'] > 25] 

2. Handling Missing Data

 Check for missing values 
print(df.isnull().sum())

Fill missing values 
df.fillna(0, inplace=True)

Drop rows with missing data 
df.dropna(inplace=True) 

3. GroupBy & Aggregation

 Group by a column and calculate mean 
grouped = df.groupby('Name')['Age'].mean()

Multiple aggregations 
agg_results = df.groupby('Name').agg({'Age': ['mean', 'min', 'max']}) 

4. Merging & Joining DataFrames

 Merge two DataFrames 
df2 = pd.DataFrame({'Name': ['Alice', 'Bob'], 'Salary': [50000, 60000]}) 
merged_df = pd.merge(df, df2, on='Name')

Concatenate DataFrames 
concatenated_df = pd.concat([df, df2], axis=1) 

5. Time Series Operations

 Convert column to datetime 
df['Date'] = pd.to_datetime(df['Date'])

Resample time series data 
df.set_index('Date', inplace=True) 
monthly_data = df.resample('M').mean() 

What Undercode Say

Pandas is a powerhouse for data manipulation, and mastering it requires hands-on practice. Here are some additional Linux/IT-related commands to complement your data workflow: