Skip to content

Instantly share code, notes, and snippets.

View thekensta's full-sized avatar

Chris Kenwright thekensta

View GitHub Profile
@thekensta
thekensta / AutoArima.R
Last active August 29, 2015 14:25
Auto Arima from data.frame embedding forecast in actuals
##
## Wrap forecast auto.arima(..) and forecast(..) into a data.frame
## Embeds the forecast into the data.frame
##
## Allow passing an EndDate so that the forecast can start mid-actuals
## (helps with visualization and exaplantion)
##
## Usage:
## Forecast.df <- AutoArimaForecast(Monthly.df, # DataFrame with
## H = 6, # Predict 6 months forward
@thekensta
thekensta / datecolumn_to_datepart.py
Last active August 29, 2015 14:22
Extract date components from Date column in pandas dataframe
# Extracting date components from a Date column in Pandas using IPython
# Converting to DatetimeIndex is 100x faster than using DataFrame.apply()
import pandas as pd
dates = pd.DataFrame({"Date": pd.date_range(start="1970-01-01", end="2037-12-31")})
print(dates.head())
# Date
# 0 1970-01-01
# 1 1970-01-02