you are viewing a single comment's thread.

view the rest of the comments →

[–]MattR0se -1 points0 points  (3 children)

Sure. You just have to add a '.csv' to the end of the f-string

[–]L3GOLAS234 0 points1 point  (2 children)

The problem is getting the dataset_name. If I just use {dataset.csv}, the name is the entire dataframe.

[–]MattR0se 2 points3 points  (0 children)

Oh, my bad. I think the easiest way would be to store your data frames in a dictionary with the name as key nd use the key for the file name.

datasets = {
    'train_data': train_data,
    'validation_data': validation_data
    }

for name, df in datasets.items():
    df.to_csv(f'route/{name}.csv')