Using df[columns][df[colums]<0.5]
to segment a DataFrame in Pandas usually only showed me the rows matching this condition.
Just recently I end up getting NaN - Values shown:
Was there an update I'm missing or what is causing this behaviour usually?
Dropping all NaN with .dropna()
is obviously a fast solution to this issue, but doesn't explain the change in "behaviour".
Fix: Don't put columns in double brackets..
如果需要按一列进行比较并按多列进行过滤,请使用带有boolean indexing
DataFrame.loc
:
df.loc[df['district-heating'] < 0.5, ['id','district-heating']]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.