This website collects cookies to deliver better user experience
Appending Two DataFrames in Pandas
Appending Two DataFrames in Pandas
Let's say we have two dataframes with the same attributes and they share a physical attribute that may vary. We can combine both dataframes and differentiate using this physical attribute to make handling csv files easier.
For example, if we have descriptions of colors of skin, hair, and eyes for two dataframes, one for males and one for females, we can add a column at the end that signifies whether the attributes in a certain row belong to a male or female, all in the same dataframe (population_df) instead of 2.
Importing and reading the files
Import pandas as pd
males_df = pd.read_csv('males.csv')females_df = pd.read_csv('females.csv')
Adding a last column with the attribute used for distinction