2016-09-13 42 views
1

Pandasが提供する補間機能を使用しようとしていますが、なんらかの理由で自分のシリーズを正しい値に調整できません。私はそれらをfloat64にキャストしましたが、それは助けに見えませんでした。どんな勧告?Pandas Interpolateをシリーズ上で正しく使用できない

コード:

for feature in price_data: 
    print price_data[feature] 
    print "type:" 
    print type(price_data[feature]) 
    newSeries = price_data[feature].astype(float).interpolate() 
    print "newSeries: " 
    print newSeries 

出力:

0 178.9000 
1  0.0000 
2 178.1200 
Name: open_price, dtype: object 
type: 
<class 'pandas.core.series.Series'> 
newSeries: 
0 178.90 
1  0.00 
2 178.12 
Name: open_price, dtype: float64 

答えて

0

問題が補間するものは何もないということです。私はあなたがゼロがあるところの値を補間したいと思っています。この場合、ゼロをnp.nanに置き換えて補間します。これを行う1つの方法は、

price_data.where(price_data != 0, np.nan).interpolate() 

0 178.90 
1 178.51 
2 178.12 
Name: open_price, dtype: float64 
+0

完全に見落とされている...あなたの時間をありがとう! – user3547551

関連する問題