Pandas DataFrame describe() Method
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas DataFrame describe()
Pandas describe() is used to view some basic statistical details like percentile, mean, std, etc. of a data frame or a series of numeric values. When this method is applied to a series of strings, it returns a different output which is shown in the examples below.
Syntax: DataFrame.describe(percentiles=None, include=None, exclude=None)
Parameters:
- percentile: list like data type of numbers between 0-1 to return the respective percentile
- include: List of data types to be included while describing dataframe. Default is None
- exclude: List of data types to be Excluded while describing dataframe. Default is None
Return type: Statistical summary of data frame.
Dataset used
To download the data set used in the following example, click here. In the following examples, the data frame used contains data from some NBA players. The image of the data frame before any operations are attached below.

Pandas describe() behavior for numeric dtypes
In this example, the data frame is described and [‘object’] is passed to include a parameter to see a description of the object series. [.20, .40, .60, .80] is passed to the percentile parameter to view the respective percentile of the Numeric series.
Python3
# importing pandas moduleimport pandas as pd # importing regex moduleimport re # making data framedata = pd.read_csv( # removing null values to avoid errorsdata.dropna(inplace=True) # percentile listperc = [.20, .40, .60, .80] # list of dtypes to includeinclude = ['object', 'float', 'int'] # calling describe methoddesc = data.describe(percentiles=perc, include=include) # displaydesc |
Output:
As shown in the output image, the Statistical description of the Dataframe was returned with the respectively passed percentiles. For the columns with strings, NaN was returned for numeric operations.

Describing series of strings
In this example, the described method is called by the Name column to see the behavior with the object data type.
Python3
# importing pandas moduleimport pandas as pd # importing regex moduleimport re # making data framedata = pd.read_csv( # removing null values to avoid errorsdata.dropna(inplace=True) # calling describe methoddesc = data["Name"].describe() # displaydesc |
Output: As shown in the output image, the behavior of describe() is different with a series of strings. Different stats were returned like count of values, unique values, top, and frequency of occurrence in this case.




Please Login to comment...