7 Answers
New Answer4/16/2021 6:40:02 AM
HEWAGAMAGE LAKSHITHA SHESHAN7 Answers
New Answerok u add ratio. Now u need filter dates with max ratio for this u can use simple equal df["ratio"]==df["ratio"].max() put this equal in df[here] and u got dates with max ratio https://code.sololearn.com/co287aYKt37I/?ref=app
I know what this task is. I want to know what your problem is. you want to get a solution or you want to get knowledge of how to solve.
In sololearn python for data science course data manipulation with pandas chapter project
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'] maxindx=df['ratio'].idxmax() print(df.iloc[maxindx]) i tried like this.. its not getting perfect
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"] max_ratio = df.loc[df["ratio"]==df["ratio"].max()] print(max_ratio)
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message