Uploaded October 2020 | Updated November 2026, 3 hours ago
↓ Code Available Below! ↓
This video shows how to join pandas data frames using the merge function. Joining data that resides in different tables is a common data preparation task when creating an analytical data set from multiple sources. The merge function allows you to perform inner, outer, left and right joins by changing the how argument.
If you find this video useful, like, share and subscribe to support the channel!
► Subscribe: youtube.com/c/DataDaft?sub_confirmation=1
Code used in this Python Code Clip:
import pandas as pd
data1 = pd.DataFrame({"character": ["Goku","Vegeta", "Nappa","Gohan","Piccolo"],
"power level": [12000, 16000, 4000, 1500, 3000],
"uniform color": ["orange", "blue", "black", "orange", "purple"]})
data2 = pd.DataFrame({"character": ["Gohan","Goku", "Tien","Krillin","Yamcha"],
"power level": [1500, 12000, 2000, 2000, 1500],
"unif_color": ["purple", "orange", "green", "orange", "orange"]})
data1
data2
# Use df.merge() to join data frames
data1.merge(data2,
how = "outer", # join type
on="character") # key column to join on
# Join on multiple key columns
data1.merge(data2,
how = "outer", # join type
on = ["character", "power level"]) # join on multiple cols
# Join columns with different names
# Rename columns so that they match
data2.rename(columns={'unif_color':'uniform color'}, inplace=True)
# Then join the data
data1.merge(data2,
how = "outer",
on = ["character", "power level", "uniform color"])
* Note: YouTube does not allow greater than or less than symbols in the text description, so the code above will not be exactly the same as the code shown in the video! I will use Unicode large < and > symbols in place of the standard sized ones. .
⭐ Kite is a free AI-powered coding assistant that integrates with popular editors and IDEs to give you smart code completions and docs while you’re typing. It is a cool application of machine learning that can also help you code faster! Check it out here: kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=datadaft&utm_content=description-only
↓ Code Available Below! ↓
This video shows how to join pandas data frames using the merge function. Joining data that resides in different tables is a common data preparation task when creating an analytical data set from multiple sources. The merge function allows you to perform inner, outer, left and right joins by changing the how argument.
If you find this video useful, like, share and subscribe to support the channel!
► Subscribe: youtube.com/c/DataDaft?sub_confirmation=1
Code used in this Python Code Clip:
import pandas as pd
data1 = pd.DataFrame({"character": ["Goku","Vegeta", "Nappa","Gohan","Piccolo"],
"power level": [12000, 16000, 4000, 1500, 3000],
"uniform color": ["orange", "blue", "black", "orange", "purple"]})
data2 = pd.DataFrame({"character": ["Gohan","Goku", "Tien","Krillin","Yamcha"],
"power level": [1500, 12000, 2000, 2000, 1500],
"unif_color": ["purple", "orange", "green", "orange", "orange"]})
data1
data2
# Use df.merge() to join data frames
data1.merge(data2,
how = "outer", # join type
on="character") # key column to join on
# Join on multiple key columns
data1.merge(data2,
how = "outer", # join type
on = ["character", "power level"]) # join on multiple cols
# Join columns with different names
# Rename columns so that they match
data2.rename(columns={'unif_color':'uniform color'}, inplace=True)
# Then join the data
data1.merge(data2,
how = "outer",
on = ["character", "power level", "uniform color"])
* Note: YouTube does not allow greater than or less than symbols in the text description, so the code above will not be exactly the same as the code shown in the video! I will use Unicode large < and > symbols in place of the standard sized ones. .
⭐ Kite is a free AI-powered coding assistant that integrates with popular editors and IDEs to give you smart code completions and docs while you’re typing. It is a cool application of machine learning that can also help you code faster! Check it out here: kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=datadaft&utm_content=description-only
![How to Remove a Row From a Data Frame in Pandas (Python)
This video shows how to delete rows Data Frames in the Pandas library for Python.
If you find this video useful, like, share and subscribe to support the channel!
► Subscribe: https://www.youtube.com/c/DataDaft?sub_confirmation=1
Code used in this Python Code Clip:
import pandas as pd
import statsmodels.api as sm #(To access mtcars dataset)
mtcars = sm.datasets.get_rdataset(mtcars, datasets, cache=True).data
mtcars.head()
# Delete rows by name with df.drop()
mtcars = mtcars.drop([Mazda RX4 Wag], # Rows to drop
axis = 0) # 0 for rows
mtcars.head()
# Delete rows by index
mtcars = mtcars.drop(mtcars.index[[0,2]], # Rows indicies to drop
axis = 0) # 0 for rows
mtcars.head()
* Note: YouTube does not allow greater than or less than symbols in the text description, so the code above will not be exactly the same as the code shown in the video! I will use Unicode large < and > symbols in place of the standard sized ones. .
⭐ Kite is a free AI-powered coding assistant that integrates with popular editors and IDEs to give you smart code completions and docs while you’re typing. It is a cool application of machine learning that can also help you code faster! Check it out here: https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=datadaft&utm_content=description-only How to Remove a Row From a Data Frame in Pandas (Python)](https://i.ytimg.com/vi/9yF2l0WPENM/mqdefault.jpg)


![How to Detect and Fill Missing Values in Pandas (Python)
This video shows how to detect and fill missing values such as NaN, NA, None and the empty string in Pandas data frames. Detecting, counting and filling missing values or other odd values is a basic data exploration and cleaning step that is going to be necessary with all but the cleanest real world data sets.
If you find this video useful, like, share and subscribe to support the channel!
► Subscribe: https://www.youtube.com/c/DataDaft?sub_confirmation=1
Code used in this Python Code Clip:
import numpy as np
import pandas as pd
import statsmodels.api as sm #(To access mtcars dataset)
mtcars = sm.datasets.get_rdataset(mtcars, datasets, cache=True).data
mtcars.iloc[1:4, 2:3] = np.NaN
mtcars.iloc[1:4, 3:4] = NA
mtcars.iloc[1:4, 4:5] =
mtcars[None_col] = None
mtcars.head()
# Detect NaN and None with df.isnull() or df.isna()
null = pd.isnull(mtcars)
null.head()
# Count the total number of missing values
pd.isnull(mtcars).sum().sum()
# Detect a list of missing values with df.isin()
missing_vals = [NA, , None, np.NaN]
missing = mtcars.isin(missing_vals)
missing.head()
# Fill null values (NaN and None) with a given value:
mtcars.fillna(0).head()
# Fill a list of missing values with a given value:
missing_vals = [NA, , None, np.NaN]
missing = mtcars.isin(missing_vals) # Detect missing vals
mtcars.mask(missing, missing).head() # Fill missing with df.mask()
* Note: YouTube does not allow greater than or less than symbols in the text description, so the code above will not be exactly the same as the code shown in the video! I will use Unicode large < and > symbols in place of the standard sized ones. .
⭐ Kite is a free AI-powered coding assistant that integrates with popular editors and IDEs to give you smart code completions and docs while you’re typing. It is a cool application of machine learning that can also help you code faster! Check it out here: https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=datadaft&utm_content=description-only How to Detect and Fill Missing Values in Pandas (Python)](https://i.ytimg.com/vi/AbBZYHNYFaY/mqdefault.jpg)






![How to Concatenate Data Frames in Pandas (Python)
↓ Code Available Below! ↓
This video shows how to concatenate data frames using the pandas library in Python. Data frame concatenation, also known as pasting or binding, just means joining together two data frames that have either the same columns or the same rows. In other words, using concatenate lets you add more rows or columns to an existing data frame. Concatenation should not be confused with join (merge) operations that involve combining the records of two data tables based on one or more shared key columns.
If you find this video useful, like, share and subscribe to support the channel!
► Subscribe: https://www.youtube.com/c/DataDaft?sub_confirmation=1
Code used in this Python Code Clip:
import pandas as pd
data = pd.DataFrame({character: [Goku,Vegeta, Nappa,Gohan,Piccolo],
power level: [12000, 16000, 4000, 1500, 3000]})
data
new_rows = pd.DataFrame({character: [Tien,Yamcha, Krillin],
power level: [2000, 1600, 2000]})
new_rows
# Concatenate Data Frames by Rows
data2 = pd.concat([data, new_rows], # List of data Frames to concatenate
axis=0, # Axis = 0 to concat by row
ignore_index=True)
data2
new_cols = pd.DataFrame({uniform color: [orange, blue, black, orange,
purple, green, orange, orange],
species:[saiyan,saiyan,saiyan,half saiyan,
namak,human,human,human]})
new_cols
# Concatenate Data Frames by Columns
pd.concat([data2, new_cols], # List of data Frames to concatenate
axis=1) # Axis = 1 to concat by column
* Note: YouTube does not allow greater than or less than symbols in the text description, so the code above will not be exactly the same as the code shown in the video! I will use Unicode large < and > symbols in place of the standard sized ones. .
⭐ Kite is a free AI-powered coding assistant that integrates with popular editors and IDEs to give you smart code completions and docs while you’re typing. It is a cool application of machine learning that can also help you code faster! Check it out here: https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=datadaft&utm_content=description-only How to Concatenate Data Frames in Pandas (Python)](https://i.ytimg.com/vi/CSBtnjWf_Ng/mqdefault.jpg)