3000 explained code solutions for 75 technologies

pythonCombine 2 csv files using ID column

We'll merge data1.csv and data2.csv into output.csv

import pandas as pd
csv_1 = pd.read_csv('data1.csv')
csv_2 = pd.read_csv('data2.csv')
merged = csv_1.merge(csv_2, on='id')
merged.to_csv('output.csv', sep=',', header=True, index=False)ctrl + c
import pandas

import module for converting, parsing and merging data


reads CSV data from a given file


merges CSV data with given data based on specified ID column


column name to merge data on


save result to CSV file