Data Science · Chapter 8 of 43
pandas Basics
pandas gives you the DATAFRAME — a 2D labelled table like a spreadsheet with superpowers.
For almost any data-science project in Python, pandas is your everyday tool.
Example 1 (python)
import pandas as pd
df = pd.DataFrame({'name': ['A','B','C'], 'score': [80, 92, 75]})
print(df)Output
name score
0 A 80
1 B 92
2 C 75Create a DataFrame from a dict.
Example 2 (python)
print(df[df['score'] > 80])Output
name score
1 B 92Boolean filtering.
Key points
- DataFrame = 2D labelled table.
- Series = 1D labelled array.
- Boolean masks filter rows.
- Method chaining is idiomatic.
💡 Note: Print `df.dtypes` early — wrong dtypes are the source of half the bugs in a data project.
