【问题标题】:How can I create time index df without date in pandas of python?如何在 python 的 pandas 中创建没有日期的时间索引 df?
【发布时间】:2020-01-29 02:50:50
【问题描述】:

我想创建没有日期的时间索引 df,如下所示:

          2019/10/01  2019/10/02

00:00:00
00:00:01
00:00:02
00:00:03
...
23:59:59

我该怎么做这个df? 谢谢

【问题讨论】:

  • 您能否更具体地说明问题所在?您是否做过任何研究或尝试过什么?

标签: python pandas dataframe time


【解决方案1】:

我们有date_range,只需要使用time来选择时间

idx = pd.date_range('2020-01-01', periods=24*60*60, freq='S').time


df.index = idx

【讨论】:

    【解决方案2】:

    尝试使用:

    df.index = pd.date_range(start='00:00:00', end='23:59:59', freq='S').time
    

    【讨论】:

      猜你喜欢
      • 2017-08-13
      • 1970-01-01
      • 2019-03-16
      • 2022-01-10
      • 1970-01-01
      • 2013-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多