+ 1
worst day challange
following is my code for worst day challange. It satishfies first 4 cases but fails for 5th case. I am not able to figure out the issue . Please help me if anybody import pandas as pd df = pd.read_csv("/usercode/files/ca-covid.csv") df.drop('state', axis=1, inplace=True) df['date'] = pd.to_datetime(df['date'], format="%d.%m.%y") df['month'] = df['date'].dt.month_name() df.set_index('date', inplace=True) ip1=input() ip = ip1.title() a = df.groupby("month").get_group(ip).cases.max() #print(a) print(df[(df["cases"]==a)])
2 Respostas
+ 1
Chidambar 2400
I'm not sure if it is the same challenge, but anyway, maybe this can help you:
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']
print (df[df['ratio'] == df['ratio'].max()])
+ 1
The following code should work perfectly:
import pandas as pd
df = pd.read_csv("/usercode/files/ca-covid.csv")
df.drop('state', axis=1, inplace=True)
df['date'] = pd.to_datetime(df['date'], format="%d.%m.%y")
df['month'] = df['date'].dt.month_name()
df.set_index('date', inplace=True)
month = input()
newdata = df[(df["month"]==month)]
worst_day = newdata [(newdata['cases']== newdata ['cases'].max())]
print (worst_day )