Ich denke, wenn Sie boolean indexing
mit Filterspalte col
Verwendung loc
benötigen:
dfCombined.loc[dfCombined[col].isnull(), 'col']
Wenn alle Spalten müssen loc
weglassen werden können:
dfCombined[dfCombined[col].isnull()]
Probe:
dfCombined = pd.DataFrame({'col':[1,2,np.nan],
'col1':[4,5,6]})
print (dfCombined)
col col1
0 1.0 4
1 2.0 5
2 NaN 6
print (dfCombined.loc[dfCombined['col'].isnull(), 'col'])
2 NaN
Name: col, dtype: float64
#select second column (1)
print (dfCombined.ix[dfCombined['col'].isnull(), 1])
2 6
Name: col1, dtype: int64
print (dfCombined.iloc[dfCombined['col'].isnull(), 1])
NotImplementedError: iLocation based boolean indexing on an integer type is not available
print (dfCombined[dfCombined['col'].isnull()])
col col1
2 NaN 6
zu Ihre Frage:
Funktioniert beide Ansätze, aber mehr bevorzugt ist ix
und loc
für die Auswahl der Spalte (n) - siehe cookbook.
print (dfCombined['col'][dfCombined['col'].isnull()])
2 NaN
Name: col, dtype: float64
print (dfCombined['col'].loc[dfCombined['col'].isnull()])
2 NaN
Name: col, dtype: float64