Create Pandas profiling report

Using a .CSV file as input, we create a .HTML pandas profiling report.

This notebook is purposely concise and simple.

Script parameters

Parameters


  • input_file: String filename as input that can be read using pandas.read_csv(…)
  • output_file: String filename to save .HTML report file to

Returns


HTML pandas profiling report file saved to specified output_file

[2]:
# input parameters cell
input_file = "../data/raw/flights.csv"
output_file = "../test_output/pandas_profiling__flights.html"
profiling_config = "profiling_config.yml"
[ ]:
import pandas as pd
from pandas_profiling import ProfileReport

Read data

[3]:
df = pd.read_csv(input_file)
df.shape
[3]:
(523275, 28)

Create pandas-profiling reports

Default options used here. This script can easily be extended to allow custom themes or summary calculations.

[4]:
# create pandas profiling report and save to HTML output
profile = ProfileReport(df)
profile



[4]:

Save HTML output to file

Report output is saved to a stand-alone HTML file that can be sent to others with no further dependencies.

[5]:
# create pandas profiling report and save to HTML output
profile.to_file(output_file)
print(f"Written profiling report to {output_file}")

Written profiling report to ../test_output/pandas_profiling__flights.html
[ ]: