0

Can someone help me in this last challenge??

You are working with the COVID dataset for California, which includes the number of cases and deaths for each day of 2020. Find the day when the deaths/cases ratio was largest. To do this, you need to first calculate the deaths/cases ratio and add it as a column to the DataFrame with the name 'ratio', then find the row that corresponds to the largest value. Important: The output should be a DataFrame, containing all of the columns of the dataset for the corresponding row. ANSWER: There is something wrong here, but I can't find it. It's asking to print the row where the ratio is the maximum. import pandas as pd df = pd.read_csv("/usercode/files/ca-covid.csv") df.drop('state', axis=1, inplace=True) df.set_index('date', inplace=True) df['ratio'] = df['deaths']/df['cases'] max=0 cont=0 esse=0 for i in df['ratio']: if i > max: max = i esse = cont cont+=1 #print(esse) #df=pd.DataFrame(df) print(df.iloc[esse])

8th May 2021, 3:28 PM
Marcia Ribeiro
Marcia Ribeiro - avatar
2 Antworten
0
Question link please
8th May 2021, 3:51 PM
Aditya
Aditya - avatar
0
You are working with the COVID dataset for California, which includes the number of cases and deaths for each day of 2020. Find the day when the deaths/cases ratio was largest. To do this, you need to first calculate the deaths/cases ratio and add it as a column to the DataFrame with the name 'ratio', then find the row that corresponds to the largest value. Important: The output should be a DataFrame, containing all of the columns of the dataset for the corresponding row.
9th May 2021, 12:54 AM
Marcia Ribeiro
Marcia Ribeiro - avatar