Skip to content
IT glossary
Data and MLUpdated December 3, 2026

Pandas

A Python library for working with tables of data. It lets you load a file, clean up missing or inconsistent values, filter rows, and calculate summaries such as total sales by store.

What pandas is for

Suppose you receive a weekly CSV of support tickets and need to know which teams have the longest resolution times. With pandas, you can load the export, remove records that don't belong in the calculation, and compute a summary by team. Because the steps are written in Python, you can rerun them on next week's file without rebuilding the report by hand.

Tables, columns, and row labels

A DataFrame is a table whose columns can have different data types. In a ticket table, the team name might be text and the resolution time a number. Selecting one column with tickets['team'] gives you a Series, a one-dimensional collection of values with labels.

The row labels form the index. They start at zero by default, but they aren't the same as row positions: filtering normally preserves the original labels. If the first surviving row is labeled 8, filtered.iloc[0] selects it by position, while filtered.loc[8] finds it by label. Pandas also uses labels to align data when you assign a Series to a column, so equal lengths alone don't guarantee that the values will land on the rows you expect.

Example: median resolution time by team

Assume the CSV contains a status column, a team column, and a numeric resolution_hours column. To summarize closed tickets with a recorded resolution time:

import pandas as pd

tickets = pd.read_csv('tickets.csv')
closed = tickets.loc[tickets['status'].eq('closed')]
summary = (
    closed.dropna(subset=['resolution_hours'])
    .groupby('team', as_index=False)
    .agg(median_hours=('resolution_hours', 'median'))
)

The condition in loc produces a Boolean mask: it tells pandas which rows to keep. After dropping rows with missing times, groupby splits the remaining tickets by team and agg calculates one median per group. as_index=False keeps the team name as a regular column, which is convenient when exporting the summary or joining it to another table.

When to use it and what to watch for

Pandas is useful for exploring datasets, validating exports, and preparing features for machine learning. Most operations run in memory, and intermediate results can make peak memory use much larger than the size of the input file. If the data lives in a database and you only need a small summary, consider aggregating it in SQL before loading it into Python.

Check data types and missing values before doing arithmetic. A date column read from CSV may still contain strings, and filling a missing resolution time with zero would treat an unknown duration as an instant resolution. Also check the keys before a merge: duplicate keys on both sides produce every matching pair, which can inflate totals without raising an error.

How it comes up in interviews

A common exercise asks you to add a team-level statistic to every ticket without changing the number of rows. Explain why groupby().agg() produces a summary table while groupby().transform() can put the statistic directly on the original rows.