Pandas Data Analysis Tutorial: DataFrames, Aggregations & Missing Data
Hands-on Pandas tutorial for data analysts: read_csv, Boolean filtering, handling NaN values, groupby aggregations, and export operations.
import pandas as pd
# Creating a DataFrame from raw dictionary records
data = {
'Course': ['Java', 'Python', 'Data Science', 'MERN', 'SEO'],
'Enrollments': [120, 145, 110, 95, 80],
'Fee': [25000, 22000, 35000, 28000, 18000]
}
df = pd.DataFrame(data)
# Filter courses with enrollments over 100
popular_courses = df[df['Enrollments'] > 100]
print("Popular Courses:\n", popular_courses)
# Compute descriptive revenue metric
df['TotalRevenue'] = df['Enrollments'] * df['Fee']
print("Summary Statistics:\n", df[['Enrollments', 'TotalRevenue']].describe())
1. Series and DataFrames
Pandas is built on two core data structures: Series (1-dimensional labeled array) and DataFrame (2-dimensional tabular structure with labeled axes). It utilizes NumPy under the hood for fast vectorized C computations.
2. Data Cleaning & Aggregation Workflows
Real-world datasets contain missing values and incorrect data types. Pandas provides robust utilities like isna(), fillna(), dropna(), and type conversion with astype(). Aggregation through groupby() enables multi-dimensional group-level summaries.
- Avoid looping with iterrows(); always leverage vectorized Pandas operations for 100x faster execution.
- Use .loc for label-based indexing and .iloc for integer position-based slicing.
- Inspect DataFrame dimensions and memory usage with df.info() and df.shape.
Frequently Asked Questions
Why is Pandas preferred over basic Python lists for data manipulation?
Gain deep mastery over these concepts with direct instructor guidance, code reviews, and mock interviews at C-60 R.K Tower, 3rd Floor, RDC, Ghaziabad.
Explore Related Course Call 7503962162