pandas.DataFrame.value_counts() Method
This method is used to calculate the frequency of all values in a column separately. It takes the column name inside it as a parameter and returns a series of all the values with their respective frequencies. The important point is the that the returned series is descending in nature i.e., the value having highest frequency would be the first element of the series.
Syntax:
DataFrame.value_counts(
subset=None,
normalize=False,
sort=True,
ascending=False,
dropna=True
)
# or
DataFrame.value_counts(["col_name"])
To work with Python Pandas, we need to import the pandas library. Below is the syntax,
import pandas as pd
Let us understand with the help of an example.
Output:

need an explanation for this answer? contact us directly to get an explanation for this answer