Pandas for Beginners: 15 Operations You Will Use Every Day

Pandas for Beginners: 15 Operations You Will Use Every Day

pandas is the Python library for working with tables of data. Its core object, the DataFrame, is a table with named columns that you can load, filter, group, join and reshape with code. Most day-to-day analysis in pandas uses a small set of about 15 operations. Learn those well and you can handle the majority of real analyst tasks.

pandas has hundreds of functions, and beginners often try to learn them all. That isn't necessary. This guide covers the operations that show up in almost every analysis, in the order you'll usually need them, with the Excel or SQL equivalent where it helps.

The running example is a small orders file with the columns order_id, customer_id, order_date, region, product, quantity and revenue.

Setup

import pandas as pd

pd is the universal alias. You'll see it in every tutorial and code sample.

1. Load Data

df = pd.read_csv("orders.csv")
# also: pd.read_excel("orders.xlsx", sheet_name="2026")

read_csv and read_excel cover most files. pandas can also read directly from SQL databases, JSON and Parquet.

2. Look at the Data

df.head()        # first 5 rows
df.shape         # (rows, columns)
df.info()        # column names, types, non-null counts
df.describe()    # summary stats for numeric columns

Always run these first. info() alone catches most problems: numbers stored as text, dates not recognized, unexpected missing values.

3. Select Columns

df["revenue"]                      # one column (a Series)
df[["region", "revenue"]]          # several columns (a DataFrame)

Note the double brackets for multiple columns. It's a list of column names inside the selection brackets.

4. Filter Rows

df[df["region"] == "North"]
df[(df["region"] == "North") & (df["revenue"] > 1000)]
df[df["region"].isin(["North", "South"])]

This is the equivalent of Excel's filter or SQL's WHERE. Use & for AND and | for OR, and wrap each condition in parentheses.

5. Select Rows and Columns Together with .loc

df.loc[df["revenue"] > 1000, ["order_id", "revenue"]]

.loc[rows, columns] is the clearest way to filter and pick columns at the same time. It's also the safe way to change values in a subset of rows:

df.loc[df["region"] == "Nth", "region"] = "North"

6. Sort

df.sort_values("revenue", ascending=False)
df.sort_values(["region", "revenue"], ascending=[True, False])

7. Create New Columns

df["unit_price"] = df["revenue"] / df["quantity"]
df["is_large"] = df["revenue"] > 1000

Calculations run on the whole column at once. You don't write a loop, and you don't "drag the formula down" as in Excel.

8. Count Values

df["region"].value_counts()
df["region"].value_counts(normalize=True)   # as shares

This is one of the most useful quick checks in pandas: it shows the categories, how often each appears, and any messy spellings that need cleaning.

9. Group and Aggregate

df.groupby("region")["revenue"].sum()

df.groupby("region").agg(
    total_revenue=("revenue", "sum"),
    orders=("order_id", "count"),
    avg_order=("revenue", "mean"),
)

This is the pandas version of a PivotTable or SQL's GROUP BY. The named-aggregation style in the second example gives readable column names in one step.

10. Handle Missing Values

df.isna().sum()                       # missing per column
df["region"] = df["region"].fillna("Unknown")
df = df.dropna(subset=["revenue"])    # drop rows missing revenue

Decide column by column. Filling and dropping both change your results, so note what you did.

11. Work with Dates

df["order_date"] = pd.to_datetime(df["order_date"], dayfirst=True)
df["month"] = df["order_date"].dt.to_period("M")
df["weekday"] = df["order_date"].dt.day_name()

Once a column is a real datetime, the .dt accessor gives you year, month, weekday and more. Use dayfirst=True for day/month/year formats common in Vietnam and Europe.

12. Merge (Join) Two Tables

customers = pd.read_csv("customers.csv")
merged = df.merge(customers, on="customer_id", how="left")

how takes "inner", "left", "right" or "outer", with exactly the same meaning as SQL joins. The same traps apply too: duplicate keys multiply rows, and unmatched rows get missing values. See SQL Joins Explained. Check len(df) before and after.

13. Pivot Tables

pd.pivot_table(df, index="region", columns="month",
               values="revenue", aggfunc="sum", fill_value=0)

This produces a region × month grid, just like an Excel PivotTable.

14. Remove Duplicates

df.duplicated(subset=["order_id"]).sum()
df = df.drop_duplicates(subset=["order_id"], keep="last")

Check first, then drop, and know why the duplicates exist.

15. Save the Result

df.to_csv("orders_clean.csv", index=False)
df.to_excel("summary.xlsx", index=False)

index=False stops pandas from writing its row numbers as an extra column, a common beginner annoyance.

Putting It Together: A Five-Line Analysis

"Which region had the highest revenue per order last quarter?"

df["order_date"] = pd.to_datetime(df["order_date"], dayfirst=True)
q = df[df["order_date"].dt.to_period("Q") == "2026Q2"]
summary = q.groupby("region").agg(revenue=("revenue", "sum"), orders=("order_id", "nunique"))
summary["rev_per_order"] = summary["revenue"] / summary["orders"]
summary.sort_values("rev_per_order", ascending=False)

Load, fix types, filter, group, derive, sort: most real analyses follow this same pattern.

pandas vs Excel vs SQL

Task Excel SQL pandas
Filter AutoFilter WHERE df[condition]
Group totals PivotTable GROUP BY groupby().agg()
Lookup / join XLOOKUP JOIN merge()
New column Formula dragged down Expression in SELECT df["new"] = ...
Pivot PivotTable Conditional aggregation pivot_table()

If you already know one of these tools, most pandas concepts will feel familiar. Our Excel to Python guide covers the mindset shift, and SQL vs Python explains when to use which.

Common Beginner Mistakes

  1. Forgetting to assign the result. df.dropna() returns a new DataFrame. It doesn't change df unless you write df = df.dropna().
  2. Using and / or in filters. Use & and |, with parentheses around each condition.
  3. Chained assignment like df[df["region"] == "North"]["revenue"] = 0. It may not change anything. Use .loc instead.
  4. Looping over rows. Column-wise operations are simpler and usually far faster. If you're writing for i in range(len(df)), there's almost always a better way.
  5. Not checking row counts after merges. A silent row explosion from duplicate keys is one of the most common sources of wrong totals.

What to Learn Next

Keep our Python cheat sheet for data analysts open while you practice, and apply the 12-step data cleaning checklist to a real dataset. For structured learning, Data Analysis with Python (DataCamp) teaches these operations through interactive exercises. The DataCamp Data Scientist Career Track continues into visualization, statistics and machine learning. Browse all Data Analysis courses.

Frequently Asked Questions

Is pandas hard to learn? The basics above take a week or two of regular practice for someone comfortable with Excel. Fluency, meaning writing these without looking things up, comes from using them on real data for a few months.

Should I learn pandas or SQL first? For most analyst roles, SQL first, then pandas. They share the same concepts (filter, group, join), so learning the second is much faster.

Is pandas still relevant with newer libraries like Polars? Yes. Polars is faster for large data and growing quickly, but pandas remains the most widely used library in tutorials, job postings and existing code. The concepts transfer, so learning pandas first is a safe choice.

How big a dataset can pandas handle? Comfortably, data that fits in your computer's memory, typically up to a few million rows on a normal laptop. Beyond that, look at Polars, DuckDB or Spark.

Bottom Line

You don't need all of pandas, just 15 operations: load, inspect, select, filter, .loc, sort, new columns, value counts, group-by, missing values, dates, merge, pivot, deduplicate and save. They map directly to what you already do in Excel or SQL. Practice them on a real, messy dataset and most everyday analysis tasks become routine.

Enjoyed this article?

Share it with your network

Listings related to Pandas for Beginners: 15 Operations You Will Use Every Day