我一直在搜索是否可以使用索引为pandas
中的date
创建假人,但是还没有找到任何东西。在
我有一个由date
索引的df
dew temp
date
2010-01-02 00:00:00 129.0 -16
2010-01-02 01:00:00 148.0 -15
2010-01-02 02:00:00 159.0 -11
2010-01-02 03:00:00 181.0 -7
2010-01-02 04:00:00 138.0 -7
...
{cdi>使用一个列
^{pr2}$然后用这样的东西来制造假人
df['main_hours'] = np.where((df['date'] >= '2010-01-02 03:00:00') & (df['date'] <= '2010-01-02 05:00:00')1,0)
但是,我希望使用索引date
动态创建虚拟变量,而不使用date
作为列。在pandas
中有没有这样的方法?
任何建议都将不胜感激。在
IIUC:
或者:
^{pr2}$计时:对于50000行数据流:
或者使用
between
相关问题 更多 >
编程相关推荐