【问题标题】:Is their a way to show first date and last date on this dataset in python他们是一种在python中显示此数据集的第一个日期和最后一个日期的方法吗
【发布时间】:2021-01-09 09:45:56
【问题描述】:

你好, 我试图找到在这个数据集中找到的最小日期和最大日期,它不断返回最小和最大字段,知道如何让它生成日期吗?我曾经有过它,但知道正在退货。

【问题讨论】:

    标签: python return dataset max min


    【解决方案1】:

    Date 不是索引,因此index.min() 将给出最小索引,即 0

    data['Date'] = pd.to_datetime(data['Date'])
    
    print(data['Date'].min(), data['Date'].max())
    

    如果你想使用你的命令将日期列作为索引

    df = df.set_index('Date')
    

    【讨论】:

      猜你喜欢
      • 2012-05-29
      • 2014-08-07
      • 1970-01-01
      • 1970-01-01
      • 2018-06-20
      • 1970-01-01
      • 2021-01-08
      • 2014-12-14
      • 1970-01-01
      相关资源
      最近更新 更多