Then we can use the to_csv function to save that DataFrame as a file named STAT_GPA.csv. We saved that dataset into the variable stat_gpas. Let's say for our assignment, we only want to look at the GPAs of Statistics classes for the past 10 years and save that dataset as a CSV.
A more detailed guide on how to create a dataset from a csv can be found here. Saving a DataFrame as a CSVįor this example, we will use the GPA Dataset, a dataset that contains the GPA for courses at the University of Illinois over a 10 year period.įirst we will read in the dataset using pd.read_csv. This can be done with the pandas to_csv function. An easy way to save your dataset is to export it to a CSV file that can then be shared. After this, you may want to share these new and improved datasets with the world. Many times, you may want to make changes to your original dataset as you clean the data, filter by certain categories, and more. Saving a DataFrame to a CSV file using Pandas