0% found this document useful (0 votes)
23 views1 page

Aggregate function in Pandas.

The document provides a brief guide on using aggregate functions in Pandas, specifically for analyzing a dataset of Pokémon. It demonstrates how to calculate statistical measures such as sum, mean, median, max, min, and mode for a specific column, as well as how to count unique values and sort the DataFrame based on a column. The examples utilize the 'HP' and 'Speed' columns from a CSV file named 'Pokemon.csv'.

Uploaded by

ahlawatmanshu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

Aggregate function in Pandas.

The document provides a brief guide on using aggregate functions in Pandas, specifically for analyzing a dataset of Pokémon. It demonstrates how to calculate statistical measures such as sum, mean, median, max, min, and mode for a specific column, as well as how to count unique values and sort the DataFrame based on a column. The examples utilize the 'HP' and 'Speed' columns from a CSV file named 'Pokemon.csv'.

Uploaded by

ahlawatmanshu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Aggregate function in Pandas.

First we will import pandas.


Import pandas as pd

To work in any data first need to open data in pandas


We will store that data in a variable named df.

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.

now i need every thing like mean median max min

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

2. if i want to check all the category of any values lies in a column.


we will use the short function
ascending = True is by default

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)

You might also like