import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
//anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment. warnings.warn(‘Matplotlib is building the font cache using fc-list. This may take a moment.’)
from pandas import Series,DataFrame
#### Time Seiries Analysis **** > build-in package time datetime calendar
from datetime import datetime
now = datetime.now()
now
datetime.datetime(2016, 2, 1, 11, 11, 8, 934671) > ** display time right now **
datetime.datetime(2010, 11, 20, 0, 0) > 可见timedelta是以天为单位 #### datetime模块中的数据类型 —– - date | 以公历形式存储日历日期(年、月、日) - time | 将时间存储为时、分、秒、毫秒 - datetime | 存储时间和日期 - timedelta| 比阿诗两个datetime值之间的差(日, 秒, 毫秒) ## str transformed to datetime use ** str ** or ** strftime(invoke a formed str) ** ,datetime object and pandas.Timestamp can be formulated to string
stamp = datetime(2011, 1, 3)
str(stamp)
‘2011-01-03 00:00:00’
stamp.strftime('%Y-%m-%d')
‘2011-01-03’
stamp.strftime('%Y-%m')
‘2011-01’
value = '2011-01-03'
datetime.strptime(value, '%Y-%m-%d')
datetime.datetime(2011, 1, 3, 0, 0)
datestrs = ['7/6/2011','8/6/2011']
[datetime.strptime(x, '%m/%d/%Y') for x in datestrs]
import pandas as pdimport numpy as npimport matplotlib.pyplot as plt%matplotlib inline //anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building