Python Pandas DataFrame: info() method

Profile picture for user devanshi.srivastava
Submitted by devanshi.srivastava on

Pandas dataframe.info() function is used to get the concise summary of the dataframe. It prints information of dataframe which include the index dtype and columns, non-null values and memory usage. It is used when doing exploratory analysis of DataFrame. It is used to get a quick overview of datasets of the given dataframe.

Syntax

DataFrame.info(verbose=None, buf=None, max_cols=None, memory_usage=None, null_counts=None)

Parameters:

  • verbose: It is optional.It is used to indicate wether to print full summary or not.
  • buf: It is optional.It is used for where to send the output. By default sys.stdout. If you need to further process the output then pass the writeable buffer.
  • max_cols: It is used to determine wether to print full summary or short summary. By default the setting in pandas.options.display.max_info_columns is used here.
  • memory_usage: It is used to specify whether total memory usage of the DataFrame elements should be displayed or not.
  • show_counts: It is used to specify wether to show null counts or not.

Return:

It does not return any value it just print the information of the given dataframe.

Example

# import pandas as pd
import pandas as pd

name=['Jack','Monica','Alice','Joey','Rahul','Rohit'] #creating a dataframe
total_marks=[97,93,89,84,78,75]

df=pd.DataFrame({'Name':name,'Total_Marks':total_marks})
df.info()# print the full summary

Output:

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 6 entries, 0 to 5
Data columns (total 2 columns):
# Column     Non-Null Count Dtype
--- ------   -------------- -----
0 Name        6 non-null    object
1 Total_Marks 6 non-null    int64
dtypes: int64(1),object(1)
memory usage: 224.0+bytes