2014-07-24 120 views
1

如果我的問題很簡單,請原諒我,但在編程遊戲中我很新。我如何刪除數據集中以-開頭的所有數據,並且不會影響列的間距。在熊貓中刪除數據

20140331 220452 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 221051 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0  1.0  1.5 -32.0 -24.6  1.5 
20140331 221651 -32.0 -32.0 -0.5 -32.0  6.0  0.0  9.0  7.0  6.5 -7.6  9.0 
20140331 222252 -32.0 -32.0 -4.0 -32.0  1.5  2.0  8.5  8.0  1.5 -8.7  8.5 
20140331 222852 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 223451  0.5  1.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -24.7  1.0 
20140331 224052  9.5 -32.0 -32.0  9.0  9.5 -32.0  8.0  9.0  9.5 -4.6  9.5 
20140331 224652 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 225252 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 225852 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 230452 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 231051 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 231652 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 232252 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 232852 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 233451 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 234052 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 234652  2.5  2.0 -32.0  2.5 -32.0 -32.0  2.5  2.0 -32.0 -12.9  2.5 
20140331 235252 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
20140331 235853 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 -32.0 
+0

對不起,你想用'nan'替換負值嗎? – EdChum

+1

如果這是你想要的,你可以做'df [df <0]' – EdChum

+0

你能發佈所需的輸出 – EdChum

回答

1

使用數組掩碼來選擇所需數據,然後使用numpy的NaN進行賦值。假設這些是浮動,

df[df < 0] = np.nan