I have 5 DataFrame
with columns 'day', 'number', 'id', 'recordDay', and I put all the 5 dataframes in a dictionary
. I would like to save 5 dataframes in 5 CSV files with file names based on 'id' and 'recordDay'. Here's the example of dataframe1 and dataframe2
df1 df2
day number id recordDay day number id recordDay
2017-03-21 17 1 1990-01-01 2016-03-21 6 2 1991-02-01
2017-03-22 19 1 1990-01-01 2016-03-22 8 2 1991-02-01
2017-03-23 21 1 1990-01-01 2016-03-23 10 2 1991-02-01
Is it possible to save 5 CSV files with file names like this, 'id_1_1991_01_01.csv'
, 'id_2_1991_02_01.csv'
, 'id_3_1991_03_01.csv'
,'id_4_1991_04_01.csv'
, 'id_5_1991_05_01.csv'
Or 'id_1.csv'
...'id_5.csv'
would be better?
I used the following code, but it only saved one CSV file.
pd.concat(df_dict).to_csv('data.csv', index = False, data_format = '%Y-%m-%d)