Python pandas check if dataframe is not empty

前端 未结 4 1976
粉色の甜心
粉色の甜心 2021-02-11 11:59

I have an if statement where it checks if the data frame is not empty. The way I do it is the following:

if dataframe.empty:
    pass
else:
    #do          


        
4条回答
  •  执笔经年
    2021-02-11 12:33

    Just do

    if not dataframe.empty:
         # insert code here
    

    The reason this works is because dataframe.empty returns True if dataframe is empty. To invert this, we can use the negation operator not, which flips True to False and vice-versa.

提交回复
热议问题