2017-09-01 96 views

回答

1

to_numeric不能處理,作爲分隔符爲十萬,幾百萬,..

你應該預處理tt通過類似tt = [n.replace(',','') for n in tt]

0

tt第二個值是不是一個數字,在數量有限的定義對於許多解析器。在嘗試進行轉換之前,只需刪除逗號。

tt = ['123.00','10,614,163,994.00'] 
tt = [x.replace(',','') for x in tt] 
pd.to_numeric(tt) 
+2

請添加一些細節/澄清你的代碼。 – Dwhitz

+0

你應該註釋你的答案 – Krunal

0

如果在列表中有一個字符串,分裂他們的,然後申請pd.numeric使用列表理解,因爲pd.numeric方法的參數應該是字符串或數字的列表不是字符串單獨,。即

tt = ['123.00','10,614,163,994.00'] 

([pd.to_numeric(i.split(',')) for i in tt]) 

輸出:

[array([ 123.]), array([ 10., 614., 163., 994.])] 
+0

Downvoter你能解釋一下嗎? – Dark