Merge Data Frames
The merge() function in pandas is used for all standard database join operations. Merge operation on data frames will join two data frames based on their common column values. Let’s create a data frame.
Python3
#Creating dataframe1 df1 = pd.DataFrame({ 'Name' :[ 'Jeevan' , 'Raavan' , 'Geeta' , 'Bheem' ], 'Age' :[ 25 , 24 , 52 , 40 ], 'Qualification' :[ 'Msc' , 'MA' , 'MCA' , 'Phd' ]}) df1 |
Output:
Name Age Qualification
0 Jeevan 25 Msc
1 Raavan 24 MA
2 Geeta 52 MCA
3 Bheem 40 Phd
Now we will create another data frame.
Python3
#Creating dataframe2 df2 = pd.DataFrame({ 'Name' :[ 'Jeevan' , 'Raavan' , 'Geeta' , 'Bheem' ], 'Salary' :[ 100000 , 50000 , 20000 , 40000 ]}) df2 |
Output:
Name Salary
0 Jeevan 100000
1 Raavan 50000
2 Geeta 20000
3 Bheem 40000
Now. let’s merge these two data frames created earlier.
Python3
#Merging two dataframes df = pd.merge(df1, df2) df |
Output:
Name Age Qualification Salary
0 Jeevan 25 Msc 100000
1 Raavan 24 MA 50000
2 Geeta 52 MCA 20000
3 Bheem 40 Phd 40000
Data Processing with Pandas
Data Processing is an important part of any task that includes data-driven work. It helps us to provide meaningful insights from the data. As we know Python is a widely used programming language, and there are various libraries and tools available for data processing.
In this article, we are going to see Data Processing in Python, Loading, Printing rows and Columns, Data frame summary, Missing data values Sorting and Merging Data Frames, Applying Functions, and Visualizing Dataframes.
Table of Content
- What is Data Processing in Python?
- What is Pandas?
- Loading Data in Pandas DataFrame
- Printing rows of the Data
- Printing the column names of the DataFrame
- Summary of Data Frame
- Descriptive Statistical Measures of a DataFrame
- Missing Data Handing
- Sorting DataFrame values
- Merge Data Frames
- Apply Function
- By using the lambda operator
- Visualizing DataFrame
- Conclusion
Contact Us