How To Print Summary Of Your Data Frame?
Table Of Contents:
- Syntax To Print Summary Of Data Frame.
- Examples Of Printing Summary.
(1) Syntax:
DataFrame.info(verbose=None, buf=None, max_cols=None, memory_usage=None, show_counts=None)
Description:
This method prints information about a DataFrame including the index dtype and columns, non-null values and memory usage..
Parameters:
- verbose: bool, optional – Whether to print the full summary.
- buf: writable buffer, defaults to sys.stdout – Where to send the output. By default, the output is printed to sys.stdout.
- memory_usage: bool, str, optional – Specifies whether total memory usage of the DataFrame elements (including the index) should be displayed.
- show_counts: bool, optional – Whether to show the non-null counts.
- null_counts: bool, optional – Deprecated since version 1.2.0: Use show_counts instead.
(2) Examples Of Columns :
Example-1
import pandas as pd
student = {'Name':['Subrat','Abhispa','Arpita','Anuradha','Namita'],
'Roll_No':[100,101,102,103,104],
'Subject':['Math','English','Science','History','Commerce'],
'Mark':[95,88,76,73,93]}
student_object = pd.DataFrame(student)
student_object
Output:
student_object.info()
Output:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 5 entries, 0 to 4
Data columns (total 4 columns):
# Column Non-Null Count Dtype
- – – -- – – ---------- – – - –
0 Name 5 non-null object
1 Roll_No 5 non-null int64
2 Subject 5 non-null object
3 Mark 5 non-null int64
dtypes: int64(2), object(2)
memory usage: 288.0+ bytes
Example-2
import pandas as pd
path = "E:\Blogs\Pandas\Documents\Mall_Customers.csv"
customer_details = pd.read_csv(path)
customer_details
Output:
customer_details.info()
Output:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 200 entries, 0 to 199
Data columns (total 6 columns):
# Column Non-Null Count Dtype
- – – -- – – ---------- – – - –
0 CustomerID 200 non-null int64
1 Genre 200 non-null object
2 Age 200 non-null int64
3 Annual_Income_(k$) 200 non-null int64
4 Spending_Score 200 non-null int64
5 date 200 non-null object
dtypes: int64(4), object(2)
memory usage: 9.5+ KB