Cleaning and Tidying Data in Pandas
summary
Shows concrete cleaning steps using pandas: loading files with read_csv, inspecting df.head/df.info, reshaping with pd.melt() to turn wide tables into long ones, splitting combined labels with str.split() to make separate variables, and turning rows back into columns with pd.pivot_table()/reset_index. Demonstrations use Pew, Billboard, Ebola, Weather and Gapminder datasets, converting 317 songs × 81 columns into roughly 22,000 rows, deduplicating with drop_duplicates, merging on keys, and saving results to CSV.
AI-written summary · about
chapters (53)
- 0:00Introduction
- 0:18Setup: Github Repo, Jupyter Setup
- 5:35Loading Datasets - panda.read_csv()
- 7:43Dataset / Dataframe At A Glance
- 7:53Get First Rows: df.head()
- 8:58Get Columns: df.columns
- 9:15Get Index: df.index
- 9:37Get Body: df.values
- 10:46Get Shape: df.shape
- 12:04Get Summarizing Statistics: df.info()
- 13:12Filtering, Slicing a Dataset / Dataframe
- 13:25Extract a Single Column: df['col_name']
- 14:12Dataframe vs Series
- 14:41Extract N Columns: df[['col1_name', 'col2_name']]
- 15:51Panda's Version: df.version
- 16:26Extract Rows: df.iloc
- 17:30Extract Rows: df.loc vs df.iloc vs df.idx
- 18:45Extract Rows: df.iloc
- 19:37Extract Rows: df.ix - Deprecated
- 20:38Extract Multiple Rows and Columns
- 22:00Extract Rows using Boolean Subsetting
- 23:24Extract Rows using Multiple Boolean Subsetting
- 24:55Cleaning a Dataset / Dataframe
- 25:38General Issues according to a "Tidy Data" Research Paper
- 29:45Issue 1: Column Headers are Values and not Variables Names
- 30:19Load Pew Dataset
- 32:55Transform Columns into Rows: pd.melt()
- 36:59Load Billboard Dataset
- 42:00Issue 2: Multiple Variables are Stored in 1 Column
- 43:06Load Ebola Dataset
- 46:22Transform Columns into Rows: pd.melt()
- 47:14Split Column using String Manipulation through Accessors
- 51:19Extract Column / Series from Accessor Split: accessor.get()
- 53:13Add Column to Dataframe
- 54:13Contracted Form for pd.melt() and Accessor String Manipulation: pd.merge()
- 56:10Issue 3: Variables Stored in Rows And Columns
- 56:25Load Weather Dataset
- 58:30Transform Columns into Rows: pd.melt()
- 1:01:00Transform Rows into Columns
- 1:02:00Transform Rows into Columns: pd.pivot() vs pd.pivot_table()
- 1:04:30Transform Rows into Columns: pd.pivot_table()
- 1:06:19Flatten nested / hierarchical table: pd.reset_index()
- 1:07:42Issue 4: Multiple Types of Observational Unit in Same Table (i.e De-nomalized Table)
- 1:09:43Extract Type Observational Unit in new Dataframe, Drop Duplicates
- 1:11:30Create "key" for extracted observational unit dataframe
- 1:12:11Save new dataframe: pd.to_csv()
- 1:13:22Merge / Join dataframe on common columns
- 1:16:25Randomly Sample a dataframe
- 1:17:15Note on Memory Consumption between all 3 dataframes
- 1:18:25Summary from "Tidy Data" Research Paper
- 1:20:06Q&A
- 1:21:21Q&A 1: Simulating R's Chaining in Python
- 1:24:49Q&A 2: Best Practices on Braquet Notation vs Chaining
related talks
01h 24mIntroduction to Data-Analysis with Pandas
01h 31mPandas, Data Wrangling & Data Science
44mIntroduction to Pandas
01h 52mIntroduction to data analytics with pandas
42mUsing Python pandas for scientific Research
21mHow to use Pandas Efficiently
30mMessy Sensor Data: A Programmer’s Cleaning Guide
35mIdiomatic Pandas
