How to add the column 'ratio'? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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']

26th Aug 2022, 6:50 PM
Josué Varela
Josué Varela - avatar
6 Answers
+ 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
27th Aug 2022, 11:49 AM
Lothar
Lothar - avatar
+ 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.
29th Aug 2022, 1:49 PM
Lothar
Lothar - avatar
+ 1
❤️❤️❤️❤️❤️
27th Aug 2022, 5:42 PM
Josué Varela
Josué Varela - avatar
+ 1
Okay
28th Aug 2022, 1:52 PM
Adu Bekele
Adu Bekele - avatar
+ 1
Hell how are you
28th Aug 2022, 6:33 PM
Adu Bekele
Adu Bekele - avatar
- 1
+2510930382890 it is my phone number,imo,WhatsApp,telegram account
28th Aug 2022, 6:34 PM
Adu Bekele
Adu Bekele - avatar