Introduction to Pandas
Winter 2025
1
Adrian Salguero
Announcements
2
Topics for Today
3
Dataset for Today
Kaggle website for dataset: https://www.kaggle.com/datasets/nelgiriyewithana/top-spotify-songs-2023?resource=download
4
What is pandas?
5
Installing pandas
Two common ways to install pandas
6
DataFrames and Series
7
column1 | column2 | column3 | column4 | column5 |
… | … | … | … | … |
… | … | … | … | … |
… | … | … | … | … |
DataFrame
Series
Reading csv file into DataFrame
8
Useful pandas commands
n = number is defined returns the first number of rows
n = number is defined, returns the last number of rows
9
Slicing and Filtering a DataFrame
Check for a single condition
new_df = df[df['column'] == "value"]
Check for multiple conditions
new_df = df[(df['column1'] == "value1") & (df['column2']>'value2')]
new_df = df[(df['column1'] == "value1") | (df['column2']>'value2')]
new_df = df[~(df['column2']>'value2')]
10
and
or
not
Visualization through pandas
11