[参考链接]:https://www.cnblogs.com/nxf-rabbit75/p/11111825.html
0. 引入工具包
import datetime
import numpy as np
import pandas as pd
from IPython.display import Image
from IPython.core.display import HTML
Image(url= "https://i.stack.imgur.com/uiXQd.png")
1.datetime库
datetime标准库有四个主要对象
- 时间 - 仅限时间,以小时,分钟,秒和微秒为单位
- 日期 - 仅年,月和日
- datetime - 时间和日期的所有组成部分
- timedelta - 最大天数的时间量
1.1datetime创建
1.2 datetime转Timestamp
1.3 datetime转np.datetime64
2.pandas库
2.1 创建Timestamp
2.2 Timestamp转datetime
从时间戳中获取日期时间
2.3 Timestamp转np.datetime64[s]
3.numpy库
NumPy没有单独的日期和时间对象,只有一个datetime64对象来表示单个时刻。 datetime模块的datetime对象具有微秒精度(百万分之一秒)。 NumPy的datetime64对象允许您将其精度从小时数一直设置为阿秒(10 ^ -18)。 它的构造函数更灵活,可以采用各种输入。