+ 1
How to add the column 'ratio'?
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) dead_cases = df['cases']/df['deaths'] df['ratio'] = df['date']
6 Respuestas
+ 6
Oro Collares ,
if you are still looking for some help, see my comments in your code:
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)
dead_cases = df['cases']/df['deaths']
# >>> the task description is asking for 'deaths'/'cases' ratio, you are using 'cases'/'deaths'
df['ratio'] = df['date'] # >>> next step we have to find the max value in column 'cases'. use .max() function. this returns a dataframe
# >>> next step is to find the row where the max value is located. use .loc[...]. this also returns a dataframe
# >>> final step is to output the row / dataframe from the previous step
+ 4
Adu Bekele ,
please post only coding related questions in this q&a section. all other posts may be considered as spam.
please also do NOT post any personal data like phone number or mail address.
+ 1
❤️❤️❤️❤️❤️
+ 1
Okay
+ 1
Hell how are you
- 1
+2510930382890 it is my phone number,imo,WhatsApp,telegram account