Hey everyone,
I have a list that I made as a dataframe and I want to take this dataframe and add it to an existing CSV file with data already in it.
The csv has three columns already,
Date,Confirmed,Deaths
2/29/2020,2,0
3/1/2020,3,0
3/2/2020,4,0
3/3/2020,4,0
3/4/2020,4,0
3/5/2020,5,0
3/6/2020,5,0
3/7/2020,6,0
3/8/2020,7,0
3/9/2020,7,0
...
My column I want to add is "New Cases". Yes, you can guess what this is about.....
I used this code and figured out quickly that this overwrites the whole CSV:
df = pd.DataFrame(data={"New_Cases": case_list})
df.to_csv("./Cook County.csv", sep=',',index=False)
I have a list that I made as a dataframe and I want to take this dataframe and add it to an existing CSV file with data already in it.
The csv has three columns already,
Date,Confirmed,Deaths
2/29/2020,2,0
3/1/2020,3,0
3/2/2020,4,0
3/3/2020,4,0
3/4/2020,4,0
3/5/2020,5,0
3/6/2020,5,0
3/7/2020,6,0
3/8/2020,7,0
3/9/2020,7,0
...
My column I want to add is "New Cases". Yes, you can guess what this is about.....

I used this code and figured out quickly that this overwrites the whole CSV:
df = pd.DataFrame(data={"New_Cases": case_list})
df.to_csv("./Cook County.csv", sep=',',index=False)