info(): Details of DataFrame

Pandas

We can get summary of DataFrame by using info().

verboseBool,optional, to print full summary or exclude about columns. It follows the setting at pandas.options.display.max_info_columns (default = 100 )
bufOutput to write to buffer. default is sys.stdout
max_colsInt ,When to switch from the verbose to the truncated output
memory_usageMinimum value appearing in the column
null_counts25th percentile of objects in the column
We get information about index dtype and column dtype, memory uses and non-null value.

verbose

Let us use one sample DataFrame.
import pandas as pd 
my_dict={
	'NAME':['Ravi','Raju','Alex'],
	'ID':[1,2,3],'MATH':[30,40,50],
	'ENGLISH':[20,30,40]
	}
my_data = pd.DataFrame(data=my_dict)
print(my_data.info())
Output


RangeIndex: 3 entries, 0 to 2
Data columns (total 4 columns):
NAME       3 non-null object
ID         3 non-null int64
MATH       3 non-null int64
ENGLISH    3 non-null int64
dtypes: int64(3), object(1)
memory usage: 176.0+ bytes
None
We will use verbose=False and check the output ( we will get same output as above if we use verbose=True)
my_data.info(verbose=False)
Output

RangeIndex: 3 entries, 0 to 2
Columns: 4 entries, NAME to ENGLISH
dtypes: int64(3), object(1)
memory usage: 176.0+ bytes
Above output depends on the Pandas setting , check details like here.
print(pd.options.display.max_info_columns) # 100 

max_cols

If our DataFrame has less than the max_cols value, then truncated output is used. In our DataFrame we have 4 columns, so till the value 3 we will get truncated output. By using max_cols=4 the full summary will be displayed.
my_data.info(max_cols=3)
Output

RangeIndex: 3 entries, 0 to 2
Columns: 4 entries, NAME to ENGLISH
dtypes: int64(3), object(1)
memory usage: 176.0+ bytes
Let us change the value to max_cols=4
my_data.info(max_cols=4)
The output is full details like shown above ( first display of code )

memory_usage

We can get information about memory uses
my_data.info(memory_usage='deep')

buf

We can send the output to buffer, by default the output is printed to sys.stdout.
Pandas DataFrame Data types Describe head
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer