2017-12-09 3 views
-4

は私が助けてください打つ:値エラー上記の最後の行で PYTHON:シンプルフロート変換はなぜ機能していませんか?この単純な変換がうまくいかないのはなぜ

print(getx) 

Date 
2017-12-08 -4.484884 
Name: CCI, dtype: float64 

chkccisplt=getx 
type(getx) 
chksplt=str(getx) 
type(chksplt) 
print(chksplt) 
Date 
2017-12-08 -4.484884 
Name: CCI, dtype: float64 
chkdt,chkcci=chksplt.split(" ") 
print(chkdt) 
Date 
2017-12-08 
print(chkcci) 
-4.484884 
Name: CCI, dtype: float64 
chkcci=chkcci.strip() 
chkcciflt=float(chkcci) 

**ValueError: could not convert string to float: '-4.484884\nName: CCI, dtype: 
float64'** 

をバックスローされます。 あなたのすべての回答を事前におねがいします。

chkcci=chkcci.split('\n')[0].strip() 

+0

エラーメッセージを再度読みます。文字列 '' -4.484884 \ nName:CCI、dtype: float64''は正しいfloat番号ではありません。 – furas

答えて

1

変更するには、この行を

chkcci=chkcci.strip() 

あなたは '名前:' 削除する必要が浮かぶようにデータを変換する部分を。

+0

Yagccept answer saar。 –

関連する問題