Compared to SQL, Python data analysis is better suited for: data cleaning and preprocessing (complex data transformations that Excel and SQL handle poorly); statistical modeling and machine learning (not just description, but prediction); automated report generation (Python scripts run on schedule, automatically generating analysis reports); visualization (interactive charts, richer customization). Typical learning path: master SQL first (data extraction, 2-4 weeks) → then Python data analysis (processing + visualization, 4-8 weeks) → extend based on direction (machine learning/automated reporting, etc.).
## Core pandas Operations
pandas DataFrame is the core data structure in Python data analysis (equivalent to data.frame in R or tables in Excel). Must-master operations:
“`python
import pandas as pd
# Read data
df = pd.read_csv(‘data.csv’)
df = pd.read_excel(‘data.xlsx’)
# Basic exploration
df.head() # First 5 rows
df.info() # Data types and missing values
df.describe() # Numerical column statistical summary
# Filtering
df[df[‘city’] == ‘Shanghai’]
df[(df[‘amount’] > 100) & (df[‘status’] == ‘paid’)]
# Aggregation (GroupBy)
df.groupby(‘city’)[‘amount’].agg([‘sum’, ‘mean’, ‘count’])
# Merge (similar to SQL JOIN)
pd.merge(df1, df2, on=’user_id’, how=’left’)
“`
## Visualization: matplotlib and seaborn
“`python
import matplotlib.pyplot as plt
import seaborn as sns
# Bar chart (comparison)
df.groupby(‘city’)[‘revenue’].sum().plot(kind=’bar’)
plt.title(‘Revenue by City’)
plt.tight_layout()
plt.savefig(‘city_revenue.png’, dpi=150)
# Heatmap (correlation matrix)
sns.heatmap(df.corr(), annot=True, cmap=’coolwarm’)
“`
## Workplace Python Data Analysis Learning Path
**Phase 1 (1-2 weeks)**: Python basic syntax (variables, lists, dictionaries, loops, functions) — recommend “Python Crash Course” Chapters 1-8. **Phase 2 (2-4 weeks)**: pandas + matplotlib hands-on — complete 3-5 full analysis cases using real business data. **Phase 3 (extend as needed)**: Plotly (interactive visualization), scikit-learn (machine learning), Jupyter/Google Colab (analysis reports).
See [SQL Data Query Basics](https://sunqi.org/sql-data-query-basics-en/) and [pandas Official Documentation](https://pandas.pydata.org/docs/).




