pandas 判断DataFrame为空:empty属性

import pandas as pd

# 创建一个空的DataFrame
df = pd.DataFrame()

# 判断DataFrame是否为空
if df.empty:
    print("DataFrame is empty.")
else:
    print("DataFrame is not empty.")

注意:empty是df的属性,不是方法,用的时候不要加()


发表评论

评论列表,共 0 条评论

    暂无评论