COVID Data Analysis project in data science with python | Sololearn: Learn to code for FREE!

+5

COVID Data Analysis project in data science with python

hi every body. i am so new in python, i had written this code for this question: 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. i do not understand what is problem exactly. can anyone help me? thanks a lot. 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'] a=df['ratio'].idxmax print(df.loc[[a]])

3/15/2021 9:39:48 AM

Mahsa Farahani

+6

print(df[df['ratio'] == df['ratio'].max()])

+1

I resolved the exercise. Here is my code. https://code.sololearn.com/cYfoYT1a0Tgw/?ref=app

+1

Line Plot Fill in the blanks to create a line chart for the COVID data showing the daily number of deaths in the month of June. df[df['month']==6]['deaths'].plot()

0

0

i editted @Wilbur Jaywright

0

df.loc[df.ratio.idxmax()] df.idxmax() method returns the location of the maximum value.

-1

Thanks, with question and answer of Igor Kostrikin I found error in my code

-1

Did any one pass this project? I used print(df[df['ratio'] == df['ratio'].max()]) and got the output as follows cases deaths ratio date 10.03.20 7 1 0.142857 Unfortunately, the test case 1 doesn't let me pass. Could any one help me on this?

-1

My way: 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'] y = df['ratio'].max() print(df[df['ratio'] == y])