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)
5 Réponses
+ 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 !!!
+ 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.
+ 1
Lothar Thanks.
I had to remove all 3 lines.
Solved
I couldn't do this without you
...
0
Please help me understand the difference
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