Created
August 1, 2019 14:57
-
-
Save haoshuai999/76d183aa932ebdb3956c6cda600d2685 to your computer and use it in GitHub Desktop.
Concatenate two CSV files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import pandas as pd | |
totalEnroll = pd.read_csv("Total-Enrollment.csv") | |
interEnroll = pd.read_csv("Inter-Enrollment.csv") | |
totalArray = [] | |
for rowtotal in totalEnroll.iterrows(): | |
for rowinter in interEnroll.iterrows(): | |
if str(rowinter[1][0]) in rowtotal[1][0]: | |
totalArray.append((str(rowinter[1][0]),rowtotal[1][0],rowtotal[1][1],rowinter[1][1])) | |
df = pd.DataFrame(totalArray) | |
df.to_csv(path_or_buf='output.csv', header=True, index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment