-1
$\begingroup$

I want to create 3 dataframes (i.e., gs, test and train) from the following dictionary:

datasets = {
  "gs": "gender_submission.csv",
  "test": "test.csv",
  "train": "train.csv"
}

Is it possible to create a for loop to achieve this?

$\endgroup$

2 Answers 2

0
$\begingroup$

Maybe is easy to import every dataset first (with the pandas.read_csv() function) and then use pandas.concat() (info) to put them toghether.

$\endgroup$
1
  • $\begingroup$ I don't want to concat them, rather I want to load them into different datasets. $\endgroup$ Commented Jan 22, 2020 at 8:57
0
$\begingroup$

Then you can do something like:

listDataFrames=[]
for key in datasets:
    listDataFrames.append(pd.read_csv(datasets[key]))
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.