The Pandas Basics Analysts Actually Use

Ian Klosowicz

The pandas basics analysts actually use come down to 9 operations: load a file, inspect it, select and filter, clean, group and aggregate, merge, create new columns, sort, and export. That's the working set. The rest of pandas is real, and nearly all of it can wait until a job puts it in front of you.

Most tutorials teach 60 functions in 6 hours. You finish able to recite method names and unable to answer a question with a messy CSV. Analyst work needs the reverse: a small set you can write without looking anything up, applied to data that fights back.

If you haven't decided whether you need Python at all, start with whether data analysts need Python. This post assumes you've decided it's worth a few weeks.

Table of Contents

I know what it costs to learn the wrong amount of Python. I spent my first 5 to 6 months on it before I found out the job I eventually got didn't need it. My first data role ran on Google Sheets and BigQuery, heavy SQL and spreadsheets, zero Python. I use Python in data engineering now, and this is the short list I'd hand someone starting out.

What are the pandas basics for data analysts?

Nine operations cover most analyst work, and this is the order to learn them in:

  1. Load a file with read_csv or read_excel.
  2. Inspect it with head, info, shape, and describe.
  3. Select and filter the columns and rows you need.
  4. Clean nulls, data types, duplicates, and messy text.
  5. Group and aggregate with groupby and agg.
  6. Merge 2 tables on a key.
  7. Create new columns from existing ones.
  8. Sort to find the top and bottom of anything.
  9. Export the result with to_csv.

The sections below walk through each one with code, using a sales file as the example. If you can do all 9 on a dataset you didn't get from a tutorial, you can honestly put pandas on a resume.

Load a file and inspect it

Start every project with read_csv or read_excel, then inspect before you change anything. Two minutes here saves an hour of confusing errors later.

import pandas as pd
df = pd.read_csv('sales.csv')
df.head()
df.info()
df.shape
df.describe()

Each line tells you something different:

  • head() shows the first 5 rows so you can see what the columns actually contain.
  • info() lists every column with its data type and a count of non-null values.
  • shape gives you the row and column counts, which you'll want again after every merge.
  • describe() summarizes the numeric columns, which is where impossible values like negative quantities show up.

For Excel files, swap in read_excel and pass sheet_name if the workbook has more than one tab. The most useful thing info() catches is a date stored as text. It shows up as a column of type object, and you'll fix it in the cleaning step.

Select columns and filter rows

Select columns with double brackets and filter rows with a condition inside single brackets. That covers most of what you'll do to narrow a dataset down to the question you're answering.

df[['order_id', 'region', 'amount']]
east = df[df['region'] == 'East']
big_east = df[(df['region'] == 'East') & (df['amount'] > 500)]
df[df['region'].isin(['East', 'West'])]
df.loc[df['amount'] > 500, ['order_id', 'amount']]

Three details trip up almost everyone the first time:

  • Wrap each condition in parentheses when you combine them.
  • Use & and | for and and or. The words and, or will throw an error.
  • Use .loc when you want to filter rows and pick columns in the same step.

This is the pandas version of WHERE, and it's the operation you'll write most often.

Clean nulls, types, and text

Cleaning means counting the nulls, deciding what each one means, fixing the types, and standardizing text. It's where most of the real time goes, in pandas and everywhere else.

df.isna().sum()
df['amount'] = df['amount'].fillna(0)
df = df.dropna(subset=['customer_id'])
df['order_date'] = pd.to_datetime(df['order_date'])
df['region'] = df['region'].str.strip().str.title()
df = df.drop_duplicates()
df = df.rename(columns={'amt': 'amount'})

The code is easy. The judgment is the skill. A few examples of decisions you'll make constantly:

  • Fill a null with 0 only when a blank genuinely means zero. A missing amount might mean the sale failed.
  • Drop rows when the missing field makes the row useless, like an order with no customer ID.
  • Convert text dates with to_datetime before you try to group by month.
  • Run str.strip and str.title on text columns, because "East" and "east " are 2 different regions to pandas.

If you've cleaned data in Power Query, these are the same steps written as code.

Group and aggregate

Use groupby with agg to summarize a table, the same way GROUP BY works in SQL. This is the operation that turns 50,000 rows into the 6 numbers a stakeholder asked for.

df.groupby('region')['amount'].sum()
summary = df.groupby('region').agg(
  total_sales=('amount', 'sum'),
  orders=('order_id', 'nunique'),
  avg_order=('amount', 'mean')
).reset_index()

The named form inside agg lets you pick the column, the calculation, and the output name in one line. Add reset_index() at the end so the result comes back as a normal table instead of a table indexed by region.

When you need a grid with one dimension down the side and another across the top, pivot_table does it in one call: pd.pivot_table(df, index='region', columns='product', values='amount', aggfunc='sum'). Learn groupby first, then pivot_table when a report calls for the grid.

Merge 2 tables

Use merge with how='left' to attach one table to another, and check the row count before and after. Merging is the pandas version of a JOIN, and it's where the quietest mistakes happen.

orders = df.merge(customers, on='customer_id', how='left')
len(df)
len(orders)

A left merge keeps every row from your main table and fills in matches from the second one. If the row count jumps after the merge, the key repeats in the second table and you've duplicated orders. Your totals are now wrong, and nothing in pandas warns you. The 2 numbers from len() are the cheapest insurance you'll ever write.

You need 2 join types to start: left and inner. Learn the others when a problem calls for them.

Create columns, sort, and export

Create a column by assigning to a new name, sort with sort_values, and export with to_csv. These 3 finish the job and take about 10 minutes to learn.

import numpy as np
df['month'] = df['order_date'].dt.to_period('M')
df['is_large'] = df['amount'] > 500
df['tier'] = np.where(df['amount'] > 500, 'Large', 'Standard')
df.sort_values('amount', ascending=False).head(10)
summary.to_csv('summary.csv', index=False)

The dt accessor pulls parts out of a date column, like the month or the day of the week. np.where is a vectorized IF statement and the 1 place most analysts touch numpy directly. Pass index=False when you export, or you'll get an extra unnamed column of row numbers in your file.

If you want a map of what else is in the Python ecosystem, the Python libraries analysts actually use covers it. pandas is the one that carries the weight.

What to skip until a job needs it

Skip anything that solves a problem you don't have yet. The pandas documentation is huge, and these are the parts that eat weeks without showing up in an entry-level screen:

  • MultiIndex. Hierarchical indexes confuse experienced people. Use reset_index and move on.
  • Time series resampling and rolling windows. Useful for specific forecasting work, rarely tested at entry level.
  • Row-wise apply with lambda functions. Slow, hard to read, and usually replaceable with a vectorized column operation.
  • Custom aggregation functions. The built-in sum, mean, count, and nunique cover the work.
  • Performance tuning. Chunked reads and memory optimization matter on huge files, not on a portfolio dataset.
  • Plotting straight from pandas. If your role uses a BI tool, build charts there.
  • polars and other DataFrame libraries. Learn pandas first. It's the standard, and it's what interviewers ask about.

Each of these is learnable in an afternoon once a real problem calls for it. Learning them early just feels like progress.

If you know SQL, you already know most of this

If you can't write SQL yet, learn SQL first. It shows up in more job postings than pandas, and it's tested in more interviews. If you already write SQL, pandas is mostly a translation exercise:

  • WHERE becomes a boolean filter inside single brackets.
  • SELECT col1, col2 becomes df[['col1', 'col2']].
  • GROUP BY becomes groupby with agg.
  • JOIN becomes merge.
  • ORDER BY becomes sort_values.

That mapping is why the order matters. The analysts who learn SQL first pick up pandas in a fraction of the time, because the logic is already in their head and only the syntax is new. If you're still deciding, Python or SQL first lays out the sequence, and how much SQL to learn for an entry-level analyst role tells you where to stop.

How to practice without a tutorial

Pick 1 real dataset and 1 question you actually want answered, then build the answer in pandas. Tutorials teach each function in isolation. A real question forces you to chain 5 or 6 of them, hit an error, and figure out which one fixes it.

A practice project that proves the skill has 3 parts:

  • A dataset you chose, with real mess in it: nulls, text dates, duplicate rows.
  • A question a manager could plausibly ask, like which region's orders are growing fastest.
  • A short written summary of what you found and what you'd do about it.

Look things up as you go. Nobody writes pandas from memory on day 1. What gets checked is whether you can get from a messy file to a correct answer and explain it.

The same logic runs through the 90 days at Analyst Hive: the parts of each tool that matter for an analyst job, in the order that gets you hired, with no full-library tour.

What people ask about pandas for analysts

How much pandas do I need to get a data analyst job?

Enough to load a file, clean it, filter it, group it, merge 2 tables, and export the result without a tutorial open. Those 9 operations cover what entry-level work asks for. Most analyst postings list SQL and a BI tool as the requirement and pandas as a preference, so treat it as a strong addition rather than the foundation.

Should I learn pandas or SQL first?

SQL first. It appears in more job postings, gets tested in more interviews, and gets used daily in the role. Every core pandas operation has a SQL equivalent, so learning SQL first makes pandas much faster to pick up. Add pandas once your SQL is job-ready and your target roles list Python.

How long does it take to learn the pandas basics?

Most people can get through these 9 operations in a few weeks of deliberate practice on a real dataset. Someone who already writes SQL moves faster, because they only need the syntax. Practice means writing the code against messy data and fixing your own errors.

Do I need numpy to use pandas?

Not as a separate subject. pandas is built on numpy and calls it for you behind the scenes. The 1 place analysts commonly touch it directly is np.where, which works like a vectorized IF statement for creating conditional columns. Learn that one function when you need it and skip studying numpy on its own.

Is pandas better than Excel for analysis?

They fit different jobs. Excel is faster for small, one-off analysis and quick formatting. pandas wins when the file is large, the steps need to repeat, or you want a record of exactly what you did to the data. Every transformation lives in code, so you can rerun it on next month's file in seconds.

What should I practice pandas on?

A real, messy dataset with a question you care about. Public datasets on topics you follow, like sports, local government, or housing, work well because the data arrives with real problems. Avoid cleaned tutorial files. The mess is the point, since cleaning it is most of what the job actually involves.

If you want the full day-by-day sequence for the analyst job search, with each skill placed where it belongs, join Analyst Hive and work through it in order.