Aggregate function in Pandas.
Aggregate function in Pandas.
df=pd.read_csv(‘Pokemon.csv’)
1. here we are taking the column number and finding their mean, median, mode, sum,
min, max
this operation is done in a specific column.
print(
ndf['HP'].sum(),
ndf['HP'].mean(),
ndf['HP'].max(),
ndf['HP'].min(),
ndf['HP'].mode() #mode is used to find out the most repeated values
print(
df['Type 1'].value_counts()
)
3. if we want to short the sheet based on any column. like here we are shorting all
the values based on speed in ascending order
ascending = true is by default if we want in descending order then we will
write ascending = False.
df=df.sort_values('Speed',ascending=False)
print(df)