Time series analysis with pandas
Time series analysis with pandas. Part 2
Introduction-to-Time-Series-Analysis-with-Pandas PDF
工作日
Count Workdays vs Weekends usage in pandas
How to group time series data by Monday, Tuesday .. ? pandas
Business days in Python with two pakage business_calendar and timeboard
pandas-resample-documentation
B business day frequency C custom business day frequency (experimental) D calendar day frequency W weekly frequency M month end frequency SM semi-month end frequency (15th and end of month) BM business month end frequency CBM custom business month end frequency MS month start frequency SMS semi-month start frequency (1st and 15th) BMS business month start frequency CBMS custom business month start frequency Q quarter end frequency BQ business quarter endfrequency QS quarter start frequency BQS business quarter start frequency A year end frequency BA business year end frequency AS year start frequency BAS business year start frequency BH business hour frequency H hourly frequency T minutely frequency S secondly frequency L milliseonds U microseconds N nanoseconds
resample-interpolate-time-series-data-python
python 日期变量 判断节假日
from datetime import datetime
import pandas as pd
startdate = '2016-01-01'
enddate = '2016-12-31'
holiday = ['01-01', '05-01']
datalist = list(pd.date_range(start=startdate, end=enddate))
df = pd.DataFrame({'date':datalist})
df['month'] = df['date'].apply(lambda x: x.month)
df['day'] = df['date'].apply(lambda x: x.day)
df['weekday'] = df['date'].apply(lambda x: x.weekday()+1)
#工作日与休息日
isrest = ((df['weekday'] == 6) | (df['weekday'] == 7))
df['label'] = isrest*1
#节假日
for h in holiday:
#h = '01-01'
h_month,h_day = h.split('-')
h_index = ((df['month'] == int(h_month)) & (df['day'] == int(h_day)))
df.loc[h_index, 'label'] = 2
np.is_busday() Custom Weekmasks
Custom Frequency Ranges & Custom Business Days & Business Hour
Convert dataframe date row to a weekend / not weekend value
df['WEEKDAY'] = ((pd.DatetimeIndex(df.index).dayofweek) // 5 == 1).astype(float)
绘图
pandas-seaborn-a-guide-to-handle-visualize-data-elegantly
本文由 xigrug 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为:2018-07-24 19:03:56