text_plain_output_1.png
import pandas as pd

df_train = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-4/train.csv')
df_test = pd.read_csv('/kaggle/input/covid19-global-forecasting-week-4/test.csv')

def add_daily_measures(df):
    df.loc[0, 'Daily Cases'] = df.loc[0, 'ConfirmedCases']
    df.loc[0, 'Daily Deaths'] = df.loc[0, 'Fatalities']
    for i in range(1, len(df_world)):
        df.loc[i, 'Daily Cases'] = df.loc[i, 'ConfirmedCases'] - df.loc[i - 1, 'ConfirmedCases']
        df.loc[i, 'Daily Deaths'] = df.loc[i, 'Fatalities'] - df.loc[i - 1, 'Fatalities']
    df.loc[0, 'Daily Cases'] = 0
    df.loc[0, 'Daily Deaths'] = 0
    return df

df_world = df_train.copy()
df_world = df_world.groupby('Date', as_index=False)['ConfirmedCases', 'Fatalities'].sum()
df_world = add_daily_measures(df_world)

df_world.head()