Ow we will create these two file train_preds.csv and valid_preds.csv

How we will create these two file train_preds.csv and valid_preds.csv from first assignments.
Kindly suggest the code

Those files are given to us as part of the assignment, so you do not need to create them. If you are trying to run the notebook locally, note that you need to copy more than just the notebook file itself in order for that to work. Use the “Lab Files → Download all files” link, if that’s what you want to do.

If you are asking the more general question “how could I create my own file like that with different data”, note that the code uses the function pd.read_csv to read in the CSV file and create a Pandas DataFrame containing the data. You can find the documentation for that function by googling “pandas read_csv”. By reading that page, I learned that there is also a “to_csv” function and a “to_excel” function. Have a look!

There are other ways to do this in python that do not involve Pandas. Try googling “python write csv file” and you’ll get lots of hits.

1 Like