zoukankan      html  css  js  c++  java
  • pandas获取当前时间

    datetime.now()用于获取当前的日期和时间

    print pd.datetime.now()

    #encoding:utf8
    
    import pandas as pd
    print("(pd.datetime.now()):")
    print (pd.datetime.now())
    time = pd.Timestamp('2018-11-01')
    print("time = pd.Timestamp('2018-11-01')")
    print(time)
    time = pd.Timestamp(1588686880,unit='s')
    print("pd.Timestamp(1588686880,unit='s'):")
    print(time)
    time = pd.date_range("12:00", "23:59", freq="30min").time
    print("pd.date_range('12:00', '23:59', freq='30min').time")
    print(time)
    time = pd.date_range("12:00", "23:59", freq="H").time
    print("freq=;H;")
    print(time)
    #要转换类似日期的对象(例如字符串,时代或混合)的序列或类似列表的对象,可以使用to_datetime函数。
    # 当传递时将返回一个Series(具有相同的索引),而类似列表被转换为DatetimeIndex
    print("================================================================")
    time = pd.to_datetime(pd.Series(['Jul 31, 2009','2019-10-10', None]))
    print(time)
    
    
    
    D:Downloadpython3python3.exe D:/Download/pycharmworkspace/s.py
    (pd.datetime.now()):
    2018-05-26 21:16:50.838958
    time = pd.Timestamp('2018-11-01')
    2018-11-01 00:00:00
    pd.Timestamp(1588686880,unit='s'):
    2020-05-05 13:54:40
    pd.date_range('12:00', '23:59', freq='30min').time
    [datetime.time(12, 0) datetime.time(12, 30) datetime.time(13, 0)
     datetime.time(13, 30) datetime.time(14, 0) datetime.time(14, 30)
     datetime.time(15, 0) datetime.time(15, 30) datetime.time(16, 0)
     datetime.time(16, 30) datetime.time(17, 0) datetime.time(17, 30)
     datetime.time(18, 0) datetime.time(18, 30) datetime.time(19, 0)
     datetime.time(19, 30) datetime.time(20, 0) datetime.time(20, 30)
     datetime.time(21, 0) datetime.time(21, 30) datetime.time(22, 0)
     datetime.time(22, 30) datetime.time(23, 0) datetime.time(23, 30)]
    freq=;H;
    [datetime.time(12, 0) datetime.time(13, 0) datetime.time(14, 0)
     datetime.time(15, 0) datetime.time(16, 0) datetime.time(17, 0)
     datetime.time(18, 0) datetime.time(19, 0) datetime.time(20, 0)
     datetime.time(21, 0) datetime.time(22, 0) datetime.time(23, 0)]
    ================================================================
    0   2009-07-31
    1   2019-10-10
    2          NaT
    dtype: datetime64[ns]
    
    Process finished with exit code 0
  • 相关阅读:
    8进阶、M语言对Simulink模型的自动化操作及配置
    7进阶、Simulink回调函数
    6基础、Simulink模型保存为图片
    PCAN-USB
    Unix-Linux编程实践 学习点滴
    学一点吧
    VM中ubuntu已经正确配置了静态IP仍无法上网
    Linux在向磁盘新建文件的时候在系统层面的四步操作
    如何更有人缘?
    我的第一个javascript网页作业
  • 原文地址:https://www.cnblogs.com/ggzhangxiaochao/p/9094355.html
Copyright © 2011-2022 走看看