9. Workflow Management for AI
Activity 9.01: Creating a DAG in Airflow to Calculate the Ratio of Likes-Dislikes for Each Category
Solution
- Create an
Activity09.01
directory in theChapter09
directory to store the files for this activity. - Open your Terminal (macOS or Linux) or Command Prompt (Windows), navigate to the
Chapter09
directory, and typejupyter notebook
. The Jupyter Notebook should resemble what you can see in the following screenshot: - In the Jupyter Notebook, click the
Activity09.01
directory, create a notebook file with thePython 3
kernel, and add the following code:import json import pandas as pd # read video data df_vids = pd.read_csv('../Data/USvideos.csv.zip', compression='zip') # read category data data_cats = json.load(open('../Data/US_category_id.json', 'r')) df_cat = pd.DataFrame(data_cats) df_cat['category'] = df_cat[&apos...