You are on page 1of 2

Note: Please import the Pandas library using the below code and read the

dataset before any Pandas function.

import pandas as pd

In the below functions, df= Any Dataframe. series = A column of a dataframe

• Unique Function - This function is used to get all unique values in a particular
column.

Syntax - series.unique()

• Value_Count Function - The value_counts() function is used to get a Series


containing counts of unique values.The resulting object will be in descending
order so that the first element is the most frequently-occurring element.

Syntax - series.value_counts(normalize=False)

Parameters:

normalize # If normalize=False, the function will give counts of unique values. If


normalize=True, the function will return the relative frequencies of the unique
values.

• Columns - This function will give the list of all the column names.

Syntax - df.columns

• Applymap - This method applies a function that accepts and returns a scalar to
every element of a DataFrame.

Syntax - df.applymap(func)

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
• Sort_Values function - This function sorts a dataframe in ascending or
descending order of a passed column

Syntax: df.sort_values(by="", ascending=True, inplace=False)

Parameters:

by- Column name to sort dataframe by

ascending- When ascending=True, then the dataframe will be sorted in


ascending order. When ascending= False, then the dataframe will be sorted in
descending order.

inplace- When inplace=True, then the sorting changes will be done in the original
dataset. When inplace=False, then the sorting changes will not overwritten in the
original dataset.

• Groupby function - Groupby function is used to split the data into several
groups bases on the given criteria. The abstract definition of grouping is to
provide a mapping of labels to group names. This function can be used to create
a pivot table.

Syntax- df.groupby(by="")

Parameters:

by- Column name to group dataframe by

df.groupby() function will return groupby object. You can combine other
functions like min, max, std, mean, etc to analyze the data on the passed
function. Below is an example of passing groupby function where we need to find
the mean of each level of column A:

df.groupby(by="A").mean()

Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.

You might also like