Introduction
If you work with data, pandas is your best friend. It lets you manipulate, analyze, and visualize data with just a few lines of code.
Installation
pip install pandas
Basic Objects
- Series – 1D array with labels
- DataFrame – 2D table with rows & columns
Creating DataFrames
import pandas as pd
data = {
'Name': ['AF4', 'Shadow', 'Wolf'],
'Score': [90, 85, 95]
}
df = pd.DataFrame(data)
print(df)
Reading & Writing Files
df = pd.read_csv('file.csv')
df.to_csv('output.csv', index=False)
DataFrame Operations
print(df.describe()) # Stats summary
print(df.head()) # First few rows
df['Score'] = df['Score'] + 5
Filtering & Selection
high_scores = df[df['Score'] > 90]
print(high_scores)
Grouping and Aggregation
df.groupby('Name').mean()
Conclusion
pandas is the heart of Python data analysis. Once you get comfortable, you'll fly through any dataset like a pro.