We are going to learn about how to merge data in Python. For that, we are going to use Python's pandas library. To merge the data, we are going to use two csv files that already created in the previous section, student1.csv and student2.csv.
Now, create a merge_data.py script and write the following code in it:
import pandas as pd
df1 = pd.read_csv("student1.csv")
df2 = pd.read_csv("student2.csv")
result = pd.concat([df1, df2])
print(result)
Run the script as follows:
$ python3 merge_data.py
Output:
Id Name Gender Age Address
0 101 John Male 20 New York
1 102 Mary Female 18 London
2 103 Aditya Male 22 Mumbai
3 104 Leo Male 22 Chicago
4 105 Sam Male 21 Paris
5 106 Tina Female 23 Sydney
0 101 John Male 21 New York
1 102 Mary Female 20 London
2 103 Aditya Male...