Pandas & NumPy
Data & Arrays
Fast Operations
Pandas & NumPy for ML
Pandas and NumPy provide the foundation for data manipulation and numerical computing in Machine Learning workflows.
NumPy Array Basics
Creating and reshaping arrays
import numpy as np
a = np.array([1, 2, 3])
matrix = np.arange(12).reshape(3, 4)
print(matrix.shape) # (3, 4)
print(matrix.mean(axis=0))
Pandas DataFrames
Loading and inspecting data
import pandas as pd
df = pd.read_csv("data.csv")
print(df.head())
print(df.info())
print(df.describe())
Grouping & Aggregation
grouped = df.groupby("category")["sales"].agg(["mean", "sum", "count"])
print(grouped)
Joins & Merges
merged = df_customers.merge(df_orders, on="customer_id", how="inner")