Exporting the clean DataFrame
In the previous chapter, we performed a series of data wrangling and cleaning processes on our metadata in order to convert it into a form that was more usable. To avoid having to perform these steps again, let's save this cleaned DataFrame into a CSV file. As always, doing this with pandas happens to be extremely easy.
In the knowledge recommender notebook from Chapter 4, enter the following code in the last cell:
#Convert the cleaned (non-exploded) dataframe df into a CSV file and save it in the data folder #Set parameter index to False as the index of the DataFrame has no inherent meaning. df.to_csv('../data/metadata_clean.csv', index=False)
Your data
folder should now contain a new file, metadata_clean.csv
.
Let's create a new folder, Chapter 4
, and open a new Jupyter Notebook within this folder. Let's now import our new file into this Notebook:
import pandas as pd import numpy as np #Import data from the clean file df = pd.read_csv('../data/metadata_clean.csv...