# Python - Calculate summary statistics of columns in dataframe

Given a pandas dataframe, we have to calculate summary statistics of columns. By Pranit Sharma Last updated : September 29, 2023

Pandas is a special tool that allows us to perform complex manipulations of data effectively and efficiently. Inside pandas, we mostly deal with a dataset in the form of DataFrame. DataFrames are 2-dimensional data structures in pandas. DataFrames consist of rows, columns, and data.

## Calculating summary statistics of columns

In this summary we will get to know the mean, median, mode, max, min, etc types of details, for this purpose, we will use pandas.DataFrame.describe() method. Pandas describe() is used to view the details of statistical values like percentile, mean, std, etc. of a DataFrame or a series of integer values. This method is applied to a series of integer values, it returns a different output if it is applied to a series of strings.

The syntax of describe() method is:

```DataFrame.describe(
percentiles=None,
include=None,
exclude=None
)
```

The parameters of describe() method are:

• percentile: returns 25%, 50% or 75% values.
• include: List of data types which has to be assessed.
• exclude: List of data types which has to be excluded from the assessment.

The describe() metod returns the statistical details of DataFrame.

Let us understand with the help of an example,

## Python program to calculate summary statistics of columns in dataframe

```# Importing pandas package
import pandas as pd

# Creating two dictionaries
d1 = {
'Phy':[72,83,83,72,65,45,86],
'che':[82,63,53,92,55,75,46],
'mat':[82,63,93,62,85,75,46],
}

# Creating DataFrame
df = pd.DataFrame(d1)

# Display the DataFrame
print("Original DataFrame:\n",df,"\n\n")

# Df.describe
res = df.describe()

# Display result
print("DataFrame with type int:\n",res,"\n")
```

### Output

The output of the above program is:

Student's Section
Subscribe