1 时间操作,datetime函数
%matplotlib notebook # 画图的魔法指令
import datetime
dt = datetime.datetime(year=2017,month=11,day=24,hour=10,minute=30)
dt # datetime.datetime(2017, 11, 24, 10, 30)
print (dt) # 2017-11-24 10:30:00
2 pandas中的timestamp时间戳
# to_datetime函数把字符串转成timestamp对象
import pandas as pd
ts = pd.Timestamp('2017-11-24')
ts # Timestamp('2017-11-24 00:00:00')
ts.month # 11
ts.day # 24
ts + pd.Timedelta('5 days') # Timestamp('2017-11-29 00:00:00')
pd.to_datetime('2017-11-24')