What is describe() in pandas?

Pandas is an open-source Python library that is used in data analysis. It provides functionalities to manipulate data in the form of table structures called data frames. The describe() method displays a statistical summary of the data that consists of the mean, the standard deviation, the minimum and maximum value, and so on.

Syntax

dataFrame.describe(percentiles, include, exclude, datetime_is_numeric)

Arguments

  1. percentiles: Values between 0 and 1. Specifies the percentile to be returned in the result. (Optional)
  2. include: List of data types to include in the result. Options are None | ‘all’ | datatypes. (Optional)
  3. exclude: List of data types to exclude in the result. Options are None | ‘all’ | datatypes. (Optional)
  4. datetime_is_numeric: To treat datetime data as numeric. Set to True or False, with default as False. (Optional)

Return Value

The functions return a DataFrame object, where each row has a type of statistic that provides a summary of the columns.

Example code

#import library
import pandas as pd
#define data
data = {'Name': ['Kris', 'Kelly', 'Josh', 'Bob','Lisa'],
'Age': [16, 21, 17, 19, 20],
'Marks': [78, 56, 87, 89, 79]}
#create a DataFrame object
df = pd.DataFrame(data)
#describe the data
print(df.describe())

Free Resources