我想创建一个带有布尔值的 DataFrame,其中 np.nan == False 和任何正实值 == True。
import numpy as np
import pandas as pd
DF = pd.DataFrame({'a':[1,2,3,4,np.nan],'b':[np.nan,np.nan,np.nan,5,np.nan]})
DF.apply(bool) # Does not work
DF.where(DF.isnull() == False) # Does not work
DF[DF.isnull() == False] # Does not work