<jupyter_start><jupyter_text>Add Features<jupyter_code># Cast TIMESTAMP as datetime
df.TIMESTAMP = pd.to_datetime(df.TIMESTAMP)
df.info()
# Add Column for HOUR, MONTH, WEEKDAY
df['HOUR'] = df.TIMESTAMP.dt.hour
df['MONTH'] = df.TIMESTAMP.dt.month
df['WEEKDAY'] = df.TIMESTAMP.dt.weekday
# Import holiday csv
df_holidays = pd.read_csv('../data/holidays.csv', delimiter=';')
df_holidays.YEAR = df_holidays.YEAR.astype('str')
df_holidays.eval('TIMESTAMP = Date + YEAR', inplace=True)
df_holidays.TIMESTAMP = pd.to_datetime(df_holidays.TIMESTAMP)
# Add column IS_HOLIDAY
df['IS_HOLIDAY'] = df.TIMESTAMP.dt.date.isin(df_holidays.TIMESTAMP.dt.date) * 1
#df[df.TIMESTAMP.dt.date.isin(df_holidays.TIMESTAMP.dt.date)]['TIMESTAMP'].dt.date.unique()
df.head()
# Add columns for windspeed at the two different heights
df.eval('WS10 = (U10 ** 2 + V10 ** 2) ** 0.5', inplace=True)
df.eval('WS100 = (U100 ** 2 + V100 ** 2) ** 0.5', inplace=True)
# Add columns for wind direction at the two different heights
def uv_to_winddir(u,v):
    return (180 + 180 / np.pi * np.arctan2(u,v)) % 360

df['WD10'] = uv_to_winddir(df.U10, df.V10)
df['WD100'] = uv_to_winddir(df.U100, df.V100)
# Add columns for cardinal wind directions
def degrees_to_cardinal(d):
    dirs = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE",
            "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]
    ix = int((d + 11.25)/22.5)
    return dirs[ix % 16]

df['WD100CARD'] = df.WD100.apply(lambda x: degrees_to_cardinal(x))
df['WD10CARD'] = df.WD10.apply(lambda x: degrees_to_cardinal(x))
# Add columns for normed wind vector components (normed by ws)
df.eval('U100NORM = U100 / WS100', inplace=True)
df.eval('V100NORM = V100 / WS100', inplace=True)
# Save dataframe including new features to csv
df.to_csv('../data/GEFCom2014Data/Wind/raw_data_incl_features.csv', index = False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17479892761394103, 'fraction_numerical': 0.04825737265415549, 'mean_word_length': 5.078175895765472, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '519403', 'license': 'MIT', 'n_tokens_mistral': 837, 'n_tokens_neox': 763, 'n_words': 157, 'path': 'notebooks/0_concatenate_train_test.ipynb', 'repo_name': 'JeromeSauer/Capstone_WindPowerPredicting', 'size': '1865'}