NumPy Pandas Basics 📊🐍
These two libraries form the foundation for handling and analyzing data in Python.
1️⃣ NumPy – Numerical Python
NumPy helps with fast numerical operations and array handling.
Importing NumPy
import numpy as np
Create Arrays
arr = np.array([1, 2, 3])
print(arr)
Array Operations
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
print(a + b) # [5 7 9]
print(a * 2) # [2 4 6]
Useful NumPy Functions
np.mean(a) # Average
np.max(b) # Max value
np.arange(0, 10, 2) # [0 2 4 6 8]
2️⃣ Pandas – Data Analysis Library
Pandas is used to work with data in table format (DataFrames).
Importing Pandas
import pandas as pd
Create a DataFrame
data = {
"Name": ["Riya", "Aman"],
"Age": [24, 30]
}
df = pd.DataFrame(data)
print(df)Read CSV File
df = pd.read_csv("data.csv")Basic DataFrame Operations
df.head() # First 5 rows
df.info() # Column types
df.describe() # Stats summary
df["Age"].mean() # Average age
Filter Rows
df[df["Age"] > 25]
🎯 Why This Matters
• NumPy makes math faster and easier
• Pandas helps clean, explore, and transform data
• Essential for real-world data analysis
Practice Task:
• Create a NumPy array of 10 numbers
• Make a Pandas DataFrame with 2 columns (Name, Score)
• Filter all scores above 80
💬 Tap ❤️ for more