Python Skills Every Data Analyst Needs to Know
The Python Skills That Actually Land You a Data Analyst Job

The Python Skills That Actually Land You a Data Analyst Job

The Python Skills That Actually Land You a Data Analyst Job
SQL gets you the data. Python is what most analysts reach for once that data needs cleaning, exploring or automating in a way spreadsheets and raw queries can't handle on their own. Research from 365 Data Science, based on an analysis of over 1,000 data analyst job postings, found Python mentioned in roughly 31% of them, well behind SQL but still common enough that most analyst roles expect at least working knowledge of it.
Most of that Python work isn't machine learning. It's Pandas, NumPy and a handful of habits around cleaning messy data, exploring it, and automating the parts of the job that would otherwise eat up an afternoon every week. This guide covers exactly that, with examples you can run yourself, starting with why Python earns a place next to SQL in the first place.
SQL is great at pulling and aggregating data that already lives in a clean, structured table. Python picks up where SQL leaves off, handling the messier parts of analysis that don't fit neatly into a query.
A few things Python is genuinely good for in an analyst's day to day.
Cleaning data that's inconsistent, incomplete or spread across multiple files, which is most real data.
Exploring a dataset quickly before deciding what's even worth building a dashboard around.
Running lightweight statistical checks, like correlations or a quick hypothesis test, without switching tools.
Automating a report or a data pull that would otherwise mean repeating the same manual steps every week.
None of this requires being a software engineer. Most analysts use a fairly small, repeatable set of Pandas and NumPy patterns for almost everything they do.
Pandas is the library almost all analyst level Python work runs on. It represents data as a DataFrame, essentially a table you can filter, reshape and clean with code instead of clicking through a spreadsheet.
Task | Pandas Function |
|---|---|
Load a CSV or Excel file | read_csv(), read_excel() |
Preview the data | head(), info(), describe() |
Filter rows | df[df['column'] > value] |
Select columns | df[['col1', 'col2']] |
Handle missing values | isna(), fillna(), dropna() |
Remove duplicates | drop_duplicates() |
Group and summarize | groupby(), agg() |
Merge two datasets | merge(), concat() |
Here's a common cleaning routine on a sales dataset.
import pandas as pd
df = pd.read_csv('sales_data.csv')
# check what you're working with
print(df.info())
print(df.isna().sum())
# drop exact duplicate rows
df = df.drop_duplicates()
# fill missing region values instead of dropping the rows
df['region'] = df['region'].fillna('Unknown')
# drop rows where the order amount itself is missing, since that can't be estimated
df = df.dropna(subset=['order_amount'])
# standardize a text column
df['customer_name'] = df['customer_name'].str.strip().str.title()
A habit worth building early. Run info() and isna().sum() on every new dataset before doing anything else. Knowing exactly which columns have missing data, and how much, shapes almost every decision you make afterward.
NumPy sits underneath Pandas and handles the actual numerical computation. Most analysts don't use it directly as often as Pandas, but a few operations come up constantly, especially once you're working with arrays or doing anything mathematical at scale.
Task | NumPy Function |
|---|---|
Create an array | np.array() |
Basic stats | np.mean(), np.median(), np.std() |
Conditional logic on arrays | np.where() |
Handle missing values in math | np.nan, np.nanmean() |
Generate ranges | np.arange(), np.linspace() |
Random sampling | np.random.choice() |
import numpy as np
order_amounts = df['order_amount'].to_numpy()
average = np.mean(order_amounts)
std_dev = np.std(order_amounts)
# flag orders more than 2 standard deviations above average as outliers
df['is_outlier'] = np.where(
df['order_amount'] > average + (2 * std_dev),
True,
False
)
This kind of outlier flag is a good example of where NumPy earns its place. It's the kind of calculation that's slow and awkward in a spreadsheet formula, but a couple of lines in Pandas and NumPy together.
Exploratory data analysis, usually shortened to EDA, is the step where you actually get to know a dataset before drawing any conclusions from it. Skipping this is one of the fastest ways to ship a wrong number to a stakeholder.
A reasonable EDA routine on a new dataset covers a similar checklist every time.
# shape and structure
print(df.shape)
print(df.dtypes)
# summary statistics for numeric columns
print(df.describe())
# value counts for categorical columns
print(df['region'].value_counts())
# correlations between numeric columns
print(df.corr(numeric_only=True))
Question | How to Check It |
|---|---|
How big is the dataset | df.shape |
What types are the columns | df.dtypes |
Are there missing values | df.isna().sum() |
What does the distribution look like | df.describe(), a histogram |
Are two variables related | df.corr() |
Are there obvious outliers | boxplot, or the standard deviation check above |
EDA isn't just a checklist to run through mechanically. The goal is building an honest sense of what the data can and can't actually tell you, before it ends up in a slide deck.
Visualization during EDA is usually quick and rough, meant for you to spot patterns, not for a stakeholder to see. Matplotlib and Seaborn cover almost everything an analyst needs here.
Library | Best For |
|---|---|
Matplotlib | Full control over a plot, good for custom or one off charts |
Seaborn | Faster, better looking statistical charts with less code |
Plotly | Interactive charts, useful when sharing exploration with others |
import seaborn as sns
import matplotlib.pyplot as plt
# distribution of order amounts
sns.histplot(df['order_amount'], bins=30)
plt.title('Order Amount Distribution')
plt.show()
# relationship between two numeric columns
sns.scatterplot(data=df, x='order_amount', y='customer_lifetime_value')
plt.show()
Lightweight statistical modeling usually means a correlation check, a simple linear regression, or a basic hypothesis test, not a full machine learning pipeline.
from scipy import stats
# is the difference in average order value between two regions significant
region_a = df[df['region'] == 'North']['order_amount']
region_b = df[df['region'] == 'South']['order_amount']
t_stat, p_value = stats.ttest_ind(region_a, region_b, nan_policy='omit')
print(f"p-value: {p_value}")
A p-value below 0.05 is the usual, though somewhat arbitrary, threshold analysts use to call a difference statistically significant. It's worth treating as one input into a decision, not the whole decision.
A lot of the real value Python adds to an analyst's job isn't in any single clever analysis. It's in automating the report that currently takes an hour of manual copy pasting every Monday morning.
A common pattern looks like this.
import pandas as pd
from datetime import datetime
def generate_weekly_report(filepath):
df = pd.read_csv(filepath)
summary = df.groupby('region').agg(
total_revenue=('order_amount', 'sum'),
total_orders=('order_id', 'count'),
avg_order_value=('order_amount', 'mean')
).reset_index()
output_path = f"weekly_report_{datetime.now().strftime('%Y_%m_%d')}.csv"
summary.to_csv(output_path, index=False)
return output_path
generate_weekly_report('weekly_sales.csv')
Once a script like this exists, it can run on a schedule, feed a dashboard automatically, or get triggered whenever a new file lands in a folder. That's usually a bigger time saver over a year than any single advanced technique.
Here's a short example that combines cleaning, EDA and a bit of automation, the kind of script an analyst might actually run every week.
Say the goal is a clean weekly summary of revenue by region, with obvious data issues flagged before anyone sees the numbers.
import pandas as pd
import numpy as np
df = pd.read_csv('weekly_sales.csv')
# clean
df = df.drop_duplicates()
df['region'] = df['region'].fillna('Unknown')
df = df.dropna(subset=['order_amount'])
# flag outliers
mean_val = df['order_amount'].mean()
std_val = df['order_amount'].std()
df['is_outlier'] = np.where(
df['order_amount'] > mean_val + (2 * std_val), True, False
)
# summarize
summary = df.groupby('region').agg(
total_revenue=('order_amount', 'sum'),
total_orders=('order_id', 'count'),
outlier_count=('is_outlier', 'sum')
).reset_index()
print(summary)
This single script handles the cleaning, catches anything unusual before it skews the totals, and produces a summary that's ready to share. That combination, clean data plus a quick sanity check plus automation, is most of what Python is actually doing in an analyst's workflow day to day.
Skipping the missing value check and letting fillna() or dropna() silently remove more data than intended.
Treating every outlier as an error and deleting it, instead of first checking whether it's a real, meaningful data point.
Running EDA once at the start of a project and never revisiting it as the data changes.
Reaching for a machine learning model when a groupby and a chart would have answered the question just as well.
Writing one off scripts with hardcoded file paths and values, then being unable to reuse them the following week.
Pandas and NumPy are learnable from documentation and small practice datasets on your own. Getting comfortable enough to clean a messy real world dataset, run a proper EDA, and automate a recurring report usually takes structured practice with actual feedback, not just tutorials. If that's the stage you're at, it's worth looking into a structured data analytics program that builds these exact skills through real project work instead of isolated exercises.
FAQ