Check if pandas DataFrame is Empty in Python (Examples) | Zero Rows & Columns | Logical Indicator

Published: 30 November 2022
on channel: Statistics Globe
348
5

How to test whether a pandas DataFrame is empty in the Python programming language. More details: https://statisticsglobe.com/check-if-...
Python code of this video:

import pandas as pd # Load pandas library

data1 = pd.DataFrame({'x1':[6, 7, 3, 7, 9], # Create example DataFrame
'x2':[3, 6, 4, 1, 3],
'x3':range(6, 1, - 1)})
print(data1) # Print example DataFrame

print(data1.empty) # Test if DataFrame is empty
False

data2 = pd.DataFrame() # Create empty DataFrame
print(data2) # Print empty DataFrame
Empty DataFrame
Columns: []
Index: []

print(data2.empty) # Test if DataFrame is empty
True

Follow me on Social Media:
Facebook – Statistics Globe Page:   / statisticsglobecom  
Facebook – R Programming Group for Discussions & Questions:   / statisticsglobe  
Facebook – Python Programming Group for Discussions & Questions:   / statisticsglobepython  
LinkedIn – Statistics Globe Page:   / statisticsglobe  
LinkedIn – R Programming Group for Discussions & Questions:   / 12555223  
LinkedIn – Python Programming Group for Discussions & Questions:   / 12673534  
Twitter:   / joachimschork  

Music by bensound.com


Watch video Check if pandas DataFrame is Empty in Python (Examples) | Zero Rows & Columns | Logical Indicator online without registration, duration hours minute second in high quality. This video was added by user Statistics Globe 30 November 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 348 once and liked it 5 people.