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


On this page of the site you can watch the video online Check if pandas DataFrame is Empty in Python (Examples) | Zero Rows & Columns | Logical Indicator with a duration of hours minute second in good quality, which was uploaded by the user Statistics Globe 30 November 2022, share the link with friends and acquaintances, this video has already been watched 348 times on youtube and it was liked by 5 viewers. Enjoy your viewing!