Loading video player…

Building a Report

00:00 In the last lesson, you installed the fg-data-profiling package. Now it’s time to use it to build a profile report. The components you will need to create this report are fg-data-profiling installed, we’ve done that, we need a dataset, specifically as a pandas DataFrame.

00:17 The dataset for this course is included in the course materials. And you need to know how you’d like to export your report. Typically it will be an HTML page.

00:26 That’s what we’ll start with. The code to build a profile report looks something like this. We’ll walk through it together in a second. It starts with importing the package, reading in the data, and generating the profile report.

00:40 Those are the three steps you’ll need to take. First of all, we need some data. For this course, we’re going to use this flight dataset. It’s got some date information,

00:51 where the flight originates from, where it’s going, and a bunch of other information. There’s quite a lot of columns here, and we’d like to understand it in more detail.

01:02 So jumping across to the Python script we started in the last lesson, as well as importing fg-data-profiling, we’re going to also need to import pandas.

01:11 So I’m going to import pandas as pd. Then you’re going to use pandas to read in the data, store it in a DataFrame object.

01:20 So df = pd.read_csv(). The CSV in this case is called flight_data_2024_sample.csv. Once you have the DataFrame object, you can create a profile report.

01:37 We’re going to store it in a variable called profile. So profile = ProfileReport, and you’re going to pass in the DataFrame df. Once you have your profile report object, you can use the .to_file() method to export your report into your desired format.

01:58 So profile.to_file(),

02:01 and we’ll call it flight_report.html.

02:05 I’ll save this script, and then we’ll jump over to the terminal and run the script. Because I’m using uv, I’m going to type uv run report.py.

02:16 So that’s going to take a few minutes because it’s summarizing the data, performing all the calculations, and generating the report file. The final step is to generate the HTML report file, which you can now view.

02:31 And the report looks like this. In the next lesson, we’re going to go through this report and talk about how to interpret it.

Become a Member to join the conversation.