Introduction
Data analysis is the process of inspecting, cleaning, and modeling data to discover useful information. Python has become the go-to language for data analysts because of its simplicity and powerful libraries.
In this post, I'll walk you through the core tools and workflow I use daily.
Why Python for Data Analysis?
- Easy to learn — clean syntax, readable code
- Huge ecosystem — Pandas, NumPy, Matplotlib, Seaborn, Scikit-learn
- Community support — millions of developers, tons of tutorials
- Industry standard — used at Google, Netflix, Airbnb, and more
Setting Up Your Environment
pip install pandas numpy matplotlib seaborn jupyter
Launch Jupyter Notebook:
jupyter notebook
Loading Data with Pandas
import pandas as pd
# Load a CSV file
df = pd.read_csv("data.csv")
# Preview first 5 rows
print(df.head())
# Check shape and data types
print(df.shape)
print(df.dtypes)
Cleaning the Data
Real-world data is messy. Here's how to handle common issues:
# Check for missing values
print(df.isnull().sum())
# Drop rows with missing values
df = df.dropna()
# Fill missing values with mean
df["age"] = df["age"].fillna(df["age"].mean())
# Remove duplicates
df = df.drop_duplicates()
Exploring the Data
# Summary statistics
print(df.describe())
# Value counts for a column
print(df["category"].value_counts())
# Correlation matrix
print(df.corr())
Visualizing with Matplotlib
import matplotlib.pyplot as plt
# Bar chart
df["category"].value_counts().plot(kind="bar", color="steelblue")
plt.title("Category Distribution")
plt.xlabel("Category")
plt.ylabel("Count")
plt.tight_layout()
plt.show()
# Line chart
df["sales"].plot(kind="line", figsize=(10, 4))
plt.title("Sales Over Time")
plt.show()
Key Takeaways
- Always explore your data first — shape, types, missing values
- Clean before analyzing — garbage in, garbage out
- Visualize early — charts reveal patterns numbers hide
- Document your steps — future you will thank present you
What's Next?
In the next post, I'll cover Seaborn for advanced visualizations and how to build interactive dashboards with Plotly.
Stay tuned!
