pandas Series
The one-dimensional pandas data structure — a single labelled column of data
A pandas Series is a one-dimensional labelled array — think of it as a single column in Excel with row labels. Every column in a pandas DataFrame is a Series.
Understanding Series is the foundation for understanding DataFrames. When you select one column from a DataFrame (df["Sales"]), you get a Series back.
Example
Key Points
- ✓Series = one column with row labels (index)
- ✓df["column_name"] returns a Series; df[["col1","col2"]] returns a DataFrame
- ✓Series.value_counts() — very useful: counts unique values
- ✓Series.unique() — list of unique values; .nunique() — count of unique values
- ✓Boolean Series: df["Salary"] > 60000 returns True/False for each row — used for filtering
Practice Question
What does series.value_counts() do?