Pandas Intro
6 min read
Pandas provides the DataFrame for data analysis. Read data with pd.read_csv(). Filter with boolean indexing, group with groupby(), aggregate with agg(), and join with merge(). Export results with to_csv().
Data Analysis with Pandas
pip install pandas
import pandas as pd
df = pd.read_csv("sales.csv")
print(df.head())
print(df.describe())
# Filter rows
high = df[df["revenue"] > 10000]
# Group and aggregate
by_region = df.groupby("region")["revenue"].sum()
# Save result
by_region.to_csv("result.csv")