美文网首页pandas我爱编程
2.9 Pandas时刻数据:pd.to_datetime()

2.9 Pandas时刻数据:pd.to_datetime()

作者: 夏日春风 | 来源:发表于2018-03-16 10:47 被阅读131次

    时刻数据代表时间点,是pandas的数据类型,是将值与时间点相关联的最基本类型的时间序列数据

    pandas.Timestamp()

    1--# 直接生成pandas的时刻数据 → 时间戳

    pd.Timestamp(2017,2,9,12)

    2--# 多个时间数据,将会转换为pandas的DatetimeIndex

    pd.to_datetime()  可作为index 

    3--# 多个时间数据转换为 DatetimeIndex

    4---# 当一组时间序列中夹杂其他格式数据,可用errors参数返回

    # errors = 'ignore':不可解析时返回原始输入,这里就是直接生成一般数组

    # 作业1:请通过迭代创建一个时间列表(如图,时间区间为任意一个月,这里可以用for语句),然后转化成DatetimeIndex,并print月中是多少号

    # 作业2:请如图创建一个包含时间日期的txt文件,通过open语句读取后转化成DatetimeIndex

    相关文章

      网友评论

        本文标题:2.9 Pandas时刻数据:pd.to_datetime()

        本文链接:https://www.haomeiwen.com/subject/mgffqftx.html