Writing to CSV and other delimited files
In this recipe, you will export a DataFrame to a CSV file and leverage the different parameters available to use in the DataFrame.to_csv()
writer function.
Getting ready
The file is provided in the GitHub repository for this book, which you can find here: https://github.com/PacktPublishing/Time-Series-Analysis-with-Python-Cookbook. The file is named movieboxoffice.csv
.
To prepare, let's first read the file into a DataFrame with the following code:
import pandas as pd
from pathlib import Path
filepath = Path('../../datasets/Ch4/movieboxoffice.csv')
movies = pd.read_csv(filepath,
header=0,
parse_dates=[0],
index_col...