Bra*_*air 3 python dataframe pandas
我有一个pandas数据框,我填写了这个:
import pandas.io.data as web
test = web.get_data_yahoo('QQQ')
Run Code Online (Sandbox Code Playgroud)
iPython中的数据框如下所示:
In [13]: test
Out[13]:
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 729 entries, 2010-01-04 00:00:00 to 2012-11-23 00:00:00
Data columns:
Open 729 non-null values
High 729 non-null values
Low 729 non-null values
Close 729 non-null values
Volume 729 non-null values
Adj Close 729 non-null values
dtypes: float64(5), int64(1)
Run Code Online (Sandbox Code Playgroud)
当我将一列除以另一列时,我得到一个具有令人满意的小数位数的float64结果.例如,我甚至可以将一列除以一列偏移一列test.Open[1:]/test.Close[:],并获得令人满意的小数位数.然而,当我将列除以偏移量时,我只得到1:
In [83]: test.Open[1:] / test.Close[:]
Out[83]:
Date
2010-01-04 NaN
2010-01-05 0.999354
2010-01-06 1.005635
2010-01-07 1.000866
2010-01-08 0.989689
2010-01-11 1.005393
...
In [84]: test.Open[1:] / test.Open[:]
Out[84]:
Date
2010-01-04 NaN
2010-01-05 1
2010-01-06 1
2010-01-07 1
2010-01-08 1
2010-01-11 1
Run Code Online (Sandbox Code Playgroud)
我可能错过了一些简单的东西.为了从这种计算中获得有用的价值,我需要做些什么?在此先感谢您的帮助.