Last active
December 7, 2019 09:57
-
-
Save aishwarya-singh25/4e7c163911a4b43bb9a3606d1ba994a1 to your computer and use it in GitHub Desktop.
Time Series Features
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
data = pd.read_csv('Train_SU63ISt.csv') | |
data['Datetime'] = pd.to_datetime(data['Datetime'],format='%d-%m-%Y %H:%M') | |
data.dtypes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
data = pd.read_csv('Train_SU63ISt.csv') | |
data['Datetime'] = pd.to_datetime(data['Datetime'],format='%d-%m-%Y %H:%M') | |
data['year']=data['Datetime'].dt.year | |
data['month']=data['Datetime'].dt.month | |
data['day']=data['Datetime'].dt.day | |
data['dayofweek_num']=data['Datetime'].dt.dayofweek | |
data['dayofweek_name']=data['Datetime'].dt.weekday_name | |
data.head() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
data = pd.read_csv('Train_SU63ISt.csv') | |
data['Datetime'] = pd.to_datetime(data['Datetime'],format='%d-%m-%Y %H:%M') | |
data['expanding_mean'] = data['Count'].expanding(2).mean() | |
data = data[['Datetime','Count', 'expanding_mean']] | |
data.head(10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
data = pd.read_csv('Train_SU63ISt.csv') | |
data['Datetime'] = pd.to_datetime(data['Datetime'],format='%d-%m-%Y %H:%M') | |
data['lag_1'] = data['Count'].shift(1) | |
data = data[['Datetime', 'lag_1', 'Count']] | |
data.head() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
data = pd.read_csv('Train_SU63ISt.csv') | |
data['Datetime'] = pd.to_datetime(data['Datetime'],format='%d-%m-%Y %H:%M') | |
data['lag_1'] = data['Count'].shift(1) | |
data['lag_2'] = data['Count'].shift(2) | |
data['lag_3'] = data['Count'].shift(3) | |
data['lag_4'] = data['Count'].shift(4) | |
data['lag_5'] = data['Count'].shift(5) | |
data['lag_6'] = data['Count'].shift(6) | |
data['lag_7'] = data['Count'].shift(7) | |
data = data[['Datetime', 'lag_1', 'lag_2', 'lag_3', 'lag_4', 'lag_5', 'lag_6', 'lag_7', 'Count']] | |
data.head(10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
data = pd.read_csv('Train_SU63ISt.csv') | |
data.dtypes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
data = pd.read_csv('Train_SU63ISt.csv') | |
data['Datetime'] = pd.to_datetime(data['Datetime'],format='%d-%m-%Y %H:%M') | |
data['rolling_mean'] = data['Count'].rolling(window=7).mean() | |
data = data[['Datetime', 'rolling_mean', 'Count']] | |
data.head(10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
data = pd.read_csv('Train_SU63ISt.csv') | |
data['Datetime'] = pd.to_datetime(data['Datetime'],format='%d-%m-%Y %H:%M') | |
data['Hour'] = data['Datetime'].dt.hour | |
data['minute'] = data['Datetime'].dt.minute | |
data.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment