Pandas Basics for Interviews: Load, Select and Filter Data with Confidence

A category manager opens a CSV with 12 lakh order rows five minutes before a Monday review. The business question is simple - “Which premium skincare SKUs underperformed in South India last week?” - but the answer appears only after the noise is loaded, sliced and filtered correctly.

  • Pandas turns messy business files into analyzable tables using objects like DataFrame and Series.
  • The basic workflow is: load data - inspect shape - select columns - filter rows - validate the subset.
  • Use pd.read_csv(), pd.read_excel(), pd.read_json() or pd.read_sql() depending on the source.
  • Use df["col"] or df[["col1","col2"]] for column selection; use .loc for labels and .iloc for positions.
  • Use Boolean filtering like df[df["sales"] > 100000] to keep only rows that meet a condition.
  • For multiple conditions, wrap each condition in parentheses and combine with & for AND, | for OR.
  • Always sanity-check the result with .shape, .head(), .dtypes and key missing or duplicate checks.

Big Picture: Pandas Is the Analyst’s Sieve

Pandas is not “just Python syntax.” It is the tool that lets a manager move from a raw business dump to the exact slice needed for a decision. Loading brings the file into memory; selecting chooses the variables; filtering chooses the observations.

Pandas basics workflow A five-step flow from raw business file to decision-ready subset. Load read file Inspect shape, types Select columns Filter rows Decision-ready subset From raw data dump to business answer
Pandas basics are best remembered as a sequence: bring data in, understand it, narrow it down.

Core Explanation: The Three Skills You Must Control

The core idea is simple: a Pandas DataFrame behaves like an Excel sheet with far more power. Rows usually represent observations such as orders, customers or transactions. Columns represent variables such as date, city, category, price or revenue.

1. Loading Data: Bring the Source into a DataFrame

The most common convention is:

import pandas as pd
df = pd.read_csv("orders.csv")

Here, pd is the alias for Pandas, read_csv() reads a comma-separated file, and df is the DataFrame you will work with.

2. Inspecting Data: Do Not Touch Before You Understand

After loading, your first job is to verify what you actually received. This is where many candidates rush and make wrong assumptions about column names, date formats or missing values.

df.head()
df.shape
df.info()
df.dtypes

3. Selecting Data: Choose the Columns or Positions You Need

Selection answers: “Which columns or cells do I want?” Pandas gives you three common ways.

loc versus iloc comparison A two-column comparison showing label-based and position-based selection in Pandas. .loc .iloc Uses labels column names index labels df.loc[0, "sales"] Uses positions row numbers column numbers df.iloc[0, 2] Labels are business names; positions are spreadsheet coordinates.
Use .loc when you know names; use .iloc when you know positions.

4. Filtering Data: Keep Only the Rows That Matter

Filtering answers: “Which observations meet my business condition?” The condition returns True or False for every row; Pandas keeps the rows where the condition is True.

premium = df[df["order_value"] > 5000]

south_premium = df[
    (df["region"] == "South") &
    (df["order_value"] > 5000)
]
Filtering funnel in Pandas A funnel showing how raw rows become a smaller analysis-ready subset after column selection and row filters. All rows and columns Select useful columns Apply row conditions Focused subset The Pandas filtering funnel
Filtering is a funnel: every condition should make the dataset smaller and more relevant.

Worked Example: Filter High-Value Orders

Suppose you load this mini order table.

You want only South region orders above ₹5,000.

result = df[
    (df["region"] == "South") &
    (df["order_value"] > 5000)
]

result[["order_id", "category", "order_value"]]

The row count falls from 5 to 2, which means the filter has done what a business analyst needs - reduced a broad dump into a relevant decision set.

An analyst studying Indian digital payments may download public payments data from RBI sources, load it into Pandas, select columns like instrument, month and transaction value, then filter for UPI or cards. The so what: Pandas basics are not academic syntax - they are the first step in converting official Indian market data into a clean business view.

Definitions You Should Be Able to Say Cleanly

  • Pandas: The pandas documentation says, “pandas is a Python package providing fast, flexible, and expressive data structures designed to make working with relational or labeled data both easy and intuitive.”
  • DataFrame: A two-dimensional labeled data structure with columns of potentially different types.
  • Series: A one-dimensional labeled array capable of holding any data type.
  • Selection: Choosing specific columns, rows or cells from a DataFrame.
  • Filtering: Keeping rows that satisfy a logical condition.
  • Boolean mask: A True or False series used to include or exclude rows.

PhonePe Pulse: Pandas Basics on Real Indian Payments Data

PhonePe Pulse shows how public digital payments data can be turned into state, district and category-level insights through loading, selecting and filtering.

Situation: India’s UPI ecosystem produces massive transaction activity across states, districts, categories and time periods. PhonePe Pulse made aggregated digital payments patterns easier to explore publicly, giving analysts a rich context for questions such as where adoption is broadening or which transaction categories are gaining visibility.

The move: For a student analyst, the Pandas workflow is straightforward. Load the public dataset files, select the fields that matter - state, district, quarter, transaction count, transaction value and category - and filter for the exact geography or period being studied. This is not a claim about PhonePe’s internal analytics stack; it is the correct external analyst workflow for working with such structured public data.

Public payments data becomes useful only when an analyst narrows it to the right geography, period and metric.
Public payments data becomes useful only when an analyst narrows it to the right geography, period and metric.

Outcome or lesson: The primary driver of insight is not the size of the dataset; it is the analyst’s ability to narrow the data to the right business question. Supporting drivers are clean field selection, correct time and geography filters, and validation after every cut. That is exactly what Pandas basics train you to do.

How AI Changes Pandas Basics

AI does not remove the need to know Pandas basics. It changes how quickly you can write, debug and explain them.

Load your dataset schema or a screenshot of column names into ChatGPT or Claude and ask: “Write Pandas code to load this file, select the business-critical columns, and create three interview-style filters. Explain each line.” Then run the code yourself and check df.shape after every step.

Interview Relevance

“You receive a CSV of customer transactions. How would you load it in Pandas, select relevant columns and filter for high-value customers from Mumbai?”

Say the syntax and the logic together: “I would use .loc because I am selecting by column labels, and I would use a Boolean mask because the rows must satisfy business conditions.” That sounds much stronger than just naming functions.

Common Mistake

The most common error is confusing .loc and .iloc. Candidates say “I’ll use iloc for the revenue column” even when they mean the column name. It costs them because it reveals they have memorized syntax without understanding selection logic. One-line fix: use .loc for labels and .iloc for integer positions.

What to Revise Next

Once you can load, select and filter, move to the next two layers of the Pandas journey: making the data trustworthy, then summarizing it for decisions.

Mark Lesson Complete (Pandas Basics for Interviews: Load, Select and Filter Data with Confidence)