Python pandas check if dataframe is not empty

前端 未结 4 1977
粉色の甜心
粉色の甜心 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:32

    .empty returns a boolean value

    >>> df_empty.empty
    True
    

    So if not empty can be written as

    if not df.empty:
        #Your code
    

    Check pandas.DataFrame.empty , might help someone.

提交回复
热议问题