pandas DataFrames
The core pandas data structure — a table of rows and columns for all your data work
A DataFrame is a 2-dimensional table in pandas — rows and columns, like a spreadsheet. It is the central data structure in data analysis with Python. Almost every operation you do in pandas — filtering, sorting, grouping, merging — starts with a DataFrame.
A DataFrame is essentially a dictionary of column names mapped to Series objects, all sharing the same index.
Examples
Key Points
- ✓df.info() is the first thing to run on any new dataset — shows types and null counts
- ✓df.describe() gives count, mean, std, min, max, percentiles for numeric columns
- ✓Boolean indexing: df[df["col"] > value] — the primary filter method
- ✓Use & for AND, | for OR in pandas filters — not and/or (those are Python keywords)
- ✓loc is label-based (end inclusive); iloc is position-based (end exclusive)
Practice Question
Which pandas method gives you column names, data types, and null count all at once?