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
:
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:

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:
- Author:Entropyobserver
- URL:https://tangly1024.com/article/1c6d698f-3512-81e6-90e3-f9c2ecc8b103
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!