In this tutorial, we will learn about the python pandas method df.info() method. pandas is a very popular library to analyze data in easy and simple.
The info() method allows us to learn the shape of object types of our data. This method prints information about a Data Frame including the index data types and column data types, non-null values and memory usage.
The information contains the number of columns, column labels, column data types, memory usage and range index.
info() function
It is an important and mostly used method in the python. This Method prints the information of a data frame. It prints the various information of the data frame such as index data types, column data types, non-null values and memory usage. The information contains the number of columns, column labels, column data types, memory usage and range index.
SYNTAX:
DataFrame.info(verbose=None, buf=None, max_cols=None, memory_usage=None, show_counts=None, null_counts=None)
info() function parameters
- verbose: It is used to print the full summary of the dataset. By default, it is set to ‘TRUE’ for small Data Frames and ‘FALSE’ for large Data frames.
- buf:It is a writable buffer, default to sys.stdout.
- max_cols: It specifies whether a half summary or full summary is to be printed.
- memory_usage: It specifies whether total memory usage of the data frame elements including index are should be displayed or not.
- null_counts: It is used to find the non-null counts.
Example of info() function
import pandas as pd # sample DataFrame data ={ 'A':[1,2,3,4], 'B':[None,2.5,None,4.5], 'C':['a','b','c','d'] } df = pd.DataFrame(data) df.info()
output:
RangeIndex: 4 entries, 0 to 3 Data columns (total 3 columns): 0 A 4 non-null int64 1 B 2 non-null float64 2 C 4 non-null object dtypes: float64(1), int64(1), object(1) memory usage: 224.0+ bytes