Lazy loaded image
Technology
Lazy loaded imagePandas basic
Words 260Read Time 1 min
Jan 21, 2020
Apr 20, 2025
type
status
date
slug
summary
tags
category
icon
password

Step-by-Step Pandas Learning Path 1

Step 1: Sample CSV Data

You can save this as a file named amazon_sales.csv:

notion image

Step 2: Read the CSV File

This reads the file into a DataFrame named df.

Step 3: Explore the Data

Shows the first 5 rows of the data.
Shows column types and null values.
Gives statistics for numeric columns: mean, min, max, etc.
Lists all column names.

Step 4: Add New Columns

Convert the date column and create useful new ones:
Add a "Sales" column:

notion image

Step 5: Select Data

Select a single column:
Select multiple columns:
Select specific rows by index:
Filter rows where City is Seattle:

Step 6: Group and Aggregate

Total quantity sold for each product:
Total sales per city:
Monthly sales:
Average quantity per product:
Combined stats per product:
Orders per hour of the day:
Average order value per city:
Discount vs quantity sold:
Orders per user:
Sales per category:

Step 7: Sorting

Sort by sales in descending order:
Add a sales rank:

Step 8: Clean the Data

Check for missing values:
Drop missing values:
Check for duplicates:
Drop duplicates:

Step 9: Apply Custom Functions

Add 10 percent tax to the price:
Get first word of product name:

Step 10: Save the Data

Export cleaned data to a new file:

上一篇
Matplotlib
下一篇
Pandas Intermediate