Python 通过熊猫的时间序列
数据: 使用熊猫数据帧(df),我们可以通过以下方式获取第一列的值:Python 通过熊猫的时间序列,python,pandas,Python,Pandas,数据: 使用熊猫数据帧(df),我们可以通过以下方式获取第一列的值: date, price1 2001/11/01 00:00:01am, 10 2001/11/02 00:00:02am, 20 2001/11/03 00:00:03am,
date, price1
2001/11/01 00:00:01am, 10
2001/11/02 00:00:02am, 20
2001/11/03 00:00:03am, 15
2001/11/04 00:00:04am, 30
如果我们想休息几天,你能做什么
df.price1
不工作。在[36]:rng=日期范围('2011年1月1日',周期=5,频率=H')
df.date
在[37]中:df=DataFrame({'price':[1,2,3,4,5]},index=rng)
In[38]:df
出[38]:
价格
2011-01-01 00:00:00 1
2011-01-01 01:00:00 2
2011-01-01 02:00:00 3
2011-01-01 03:00:00 4
2011-01-01 04:00:00 5
In[39]:df.index
出[39]:
[2011-01-01 00:00:00, ..., 2011-01-01 04:00:00]
长度:5,频率:H,时区:无
In[40]:df.index.values
出[40]:
阵列([1970-01-15104:00:00,1970-01-15105:00:00,1970-01-15106:00:00,
1970-01-15 107:00:00,1970-01-15 108:00:00],数据类型=日期时间64[ns])
In [36]: rng = date_range('1/1/2011', periods=5, freq='H')
In [37]: df = DataFrame({'price':[1,2,3,4,5]},index = rng)
In [38]: df
Out[38]:
price
2011-01-01 00:00:00 1
2011-01-01 01:00:00 2
2011-01-01 02:00:00 3
2011-01-01 03:00:00 4
2011-01-01 04:00:00 5
In [39]: df.index
Out[39]:
<class 'pandas.tseries.index.DatetimeIndex'>
[2011-01-01 00:00:00, ..., 2011-01-01 04:00:00]
Length: 5, Freq: H, Timezone: None
In [40]: df.index.values
Out[40]:
array([1970-01-15 104:00:00, 1970-01-15 105:00:00, 1970-01-15 106:00:00,
1970-01-15 107:00:00, 1970-01-15 108:00:00], dtype=datetime64[ns])