0

I am working on COVID 19 DATA FOR CALIFORNIA since time long now. when I print code, I get answer, ok. Sololearn, refuse. Help

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.set_index('date', inplace=True) df['ratio']=df['deaths']/(df['cases']) df=df[df[('ratio')]==(df['ratio'].max())] print (df)

28th Jun 2022, 7:50 PM
Israel Mutebi
5 Answers
+ 3
Israel Mutebi , this line is causing the problem: ... df['date'] = pd.to_datetime(df['date'], format="%d.%m.%y") ... duplicate your code and run it in the playground in one run: -> version with this line -> version without this line watch the format of the date value !!!
28th Jun 2022, 8:36 PM
Lothar
Lothar - avatar
+ 2
Israel Mutebi , the *.csv file that we load from sololearn looks like: date, state, cases, deaths 25.01.20, California,1,0 ... the date format is day.month.year(only last 2 digits) as a string. since there is no advice to modify that format, we do not need to re-format the data of this column. just omit the line i mentioned in my previous post. this is what the mentioned line is performing: the line of code converts the 'date' column from a string format (supplied from the *.csv file) to a 'datetime' object. since the code has only given the input format, it will be converted to a default format. using the code without the mentioned line has passed the test case in the exercice, so it is seen as correct.
29th Jun 2022, 9:23 AM
Lothar
Lothar - avatar
+ 1
Lothar Thanks. I had to remove all 3 lines. Solved I couldn't do this without you ...
29th Jun 2022, 6:02 PM
Israel Mutebi
0
Please help me understand the difference
28th Jun 2022, 7:51 PM
Israel Mutebi
0
Thanks Lothar I get this output in code playground meaning the code is correct? Date cases. Death ratio 2020-03-10. 7. 1. 0.142857 But my sololearn still refuse my answer? Would I be able to get that result with a wrong code??? Help
29th Jun 2022, 5:57 AM
Israel Mutebi