application_vnd.jupyter.stderr_output_3.png text_plain_output_2.png application_vnd.jupyter.stderr_output_1.png
from datetime import datetime

import pandas as pd

import pandas as pd

def convert_to_date(x):
    return datetime.strptime(x, '%Y %m')
make = pd.read_csv('../input/newcarsalesnorway/norway_new_car_sales_by_make.csv', parse_dates=[['Year', 'Month']], date_parser=convert_to_date)
make = make[['Year_Month', 'Quantity', 'Make']]

def subset_data(dataframe=make, subset=['Toyota', 'Ford', 'BMW', 'Honda', 'Peugeot']):
    """
    Function to subset the data 
    INPUT : dataframe to subset and car type list 
    OUTPUT : 5 different dataframes with the subset data
    """
    dataframe.set_index('Year_Month', inplace=True)
    toyota = dataframe[dataframe['Make'] == subset[0]]
    ford = dataframe[dataframe['Make'] == subset[1]]
    honda = dataframe[dataframe['Make'] == subset[3]]
    BMW = dataframe[dataframe['Make'] == subset[2]]
    peugeot = dataframe[dataframe['Make'] == subset[4]]
    df = pd.concat([toyota['Quantity'], ford['Quantity'], BMW['Quantity'], honda['Quantity'], peugeot['Quantity']], axis=1)
    df.columns = [subset[0], subset[1], subset[2], subset[3], subset[4]]
    return df
df = subset_data()

freq = 'M'
start_train = pd.Timestamp('2007-01-01', freq=freq)
start_test = pd.Timestamp('2016-07-01', freq=freq)
prediction_length = 2

def convert_to_date(x):
    return datetime.strptime(x, '%Y %m')
make = pd.read_csv('../input/newcarsalesnorway/norway_new_car_sales_by_make.csv', parse_dates=[['Year', 'Month']], date_parser=convert_to_date)
make = make[['Year_Month', 'Quantity', 'Make']]
make.head(3)