SwadhyAI Notes

All Python notes

Pandas Tutorial 🐼

Data Analysis Made Easy

Pandas is the most popular Python library for data manipulation and analysis. It provides two key data structures: Series (1D) and DataFrame (2D).

📊 DataFrame & Series

Series

A one-dimensional labeled array (like a column).

python
import pandas as pd
s = pd.Series([1, 3, 5])
print(s)

DataFrame

A two-dimensional data structure (like a table).

python
data = {
  "calories": [420, 380],
  "duration": [50, 40]
}
df = pd.DataFrame(data)
print(df)

📥 Reading Data

Pandas can read data from many formats like CSV, JSON, Excel, and SQL.

python
# Read CSV
df = pd.read_csv('data.csv')

# Read JSON
df = pd.read_json('data.json')

🔍 Inspecting Data

Quickly understand your data with these methods:

python
# View first 5 rows
print(df.head())

# View summary statistics (count, mean, std, min, max)
print(df.describe())

# View data types and non-null counts
print(df.info())

💡 Did You Know?

Pandas is built on top of NumPy, which makes it extremely fast for numerical operations on large datasets.