Change language

Python | Pandas dataframe.info ()

The Pandas dataframe.info() function is used to get a quick summary of the data. This is very useful when performing analytical data analysis. To get an overview of the dataset, we use the dataframe.info () function.

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

Parameters:
verbose: Whether to print the full summary. None follows the display.max_info_columns setting. True or False overrides the display.max_info_columns setting.
buf: writable buffer, defaults to sys.stdout
max_cols: Determines whether full summary or short summary is printed. None follows the display.max_info_columns setting.
memory_usage: Specifies whether total memory usage of the DataFrame elements (including index) should be displayed. None follows the display.memory_usage setting. True or False overrides the display.memory_usage setting. A value of ’deep’ is equivalent of True, with deep introspection. Memory usage is shown in human-readable units (base-2 representation).

null_counts: Whether to show the non-null counts. If None, then only show if the frame is smaller than max_info_rows and max_info_columns. If True, always show counts. If False, never show counts.

To link to the CSV file used in the code, click here

Example # 1: Use the info () function to print a complete data summary.

# import pandas as pd

import pandas as pd

 
# Create a data frame

df = pd.read_csv ( "nba.csv" )

  
# Print the data frame
df

Let’s write a complete data summary.

# print full summary
df.info ( )

Output:

As we can see in the output, the summary includes a list of all columns with their data types and the number of non-zero values ​​in each column. we also have a rangeindex provided for the index axis.

Example # 2: Use the info () function to print a short summary of the data

Note. To print the short summary, we can use the verbose parameter and set it to False.

# import pandas as pd

import pandas as pd

 
# Create data frame

df = pd.read_csv ( "nba.csv" )

 
# Print a summary
# dataframe by setting verbose = False

df.info (verbose = False )

Output:

Like us we see from the results, the summary is very clear and short. This is useful when we have thousands of attributes in a data frame.

Example # 3: Use the info () function to print a complete summary of the data and exclude null values.

Note. To print the full summary without regard to null values, we can use the null values ​​option and set it to false.

# import pandas as pd

import pandas as pd

 
# Create a data frame

df = pd.read_csv ( "nba.csv" )

 
# Print full summary of data
# with zero exclusion

df.info (verbose = True , null_counts = False )

Output:

As you can see from the output, the summary is complete, but null values ​​are excluded.

Shop

Gifts for programmers

Best laptop for Excel

$
Gifts for programmers

Best laptop for Solidworks

$399+
Gifts for programmers

Best laptop for Roblox

$399+
Gifts for programmers

Best laptop for development

$499+
Gifts for programmers

Best laptop for Cricut Maker

$299+
Gifts for programmers

Best laptop for hacking

$890
Gifts for programmers

Best laptop for Machine Learning

$699+
Gifts for programmers

Raspberry Pi robot kit

$150

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

1947 answers

PythonStackOverflow

Check if one list is a subset of another in Python

1173 answers

PythonStackOverflow

How to specify multiple return types using type-hints

1002 answers

PythonStackOverflow

Printing words vertically in Python

909 answers

PythonStackOverflow

Python Extract words from a given string

798 answers

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

606 answers

PythonStackOverflow

Python os.path.join () method

384 answers

PythonStackOverflow

Flake8: Ignore specific warning for entire file

360 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically