#Coded by Andrew
import pandas as pd
ipl_data = {'Team': ['Riders', 'Riders', 'Devils', 'Devils', 'Kings',
'Kings', 'Kings', 'Kings', 'Riders', 'Royals', 'Royals', 'Kings'],
'Rank': [1, 2, 2, 7, 3,4 ,1 ,1,2 , 4,1,2],
'Year': [2014,2015,2014,2015,2014,2015,2016,2017,2016,2014,2015,2017],
'Points':[876,789,863,673,741,812,756,999,694,701,804,690]}
df = pd.DataFrame(ipl_data)
def division(row):
result = row["Points"]/row["Rank"]
return result
df["Division1"]=df.apply(division,axis=1)
print(df[["Division1"]])
#or you can do this
df["Division2"] = df['Points']/df['Rank']
print()
print(df[["Division2"]])
On this page of the site you can watch the video online Python Bytes - Panda Dataframe Apply Function with a duration of hours minute second in good quality, which was uploaded by the user AC 10 May 2023, share the link with friends and acquaintances, this video has already been watched 698 times on youtube and it was liked by 24 viewers. Enjoy your viewing!