一般来讲下面的代码即可:
import pandas as pd
def is_na(value):
if pd.isna(value) and value != "" and value != "nan":
return False
else:
return True
不过可以根据需要魔改,比如如果传入的value可能是pandas.Dataframe
类,可以修改为:
import pandas as pd
def is_na(value):
if isinstance(value, pd.DataFrame):
return value.empty
if pd.isna(value) and value != "" and value != "nan":
return False
else:
return True