Skip to content

Instantly share code, notes, and snippets.

@StevenReitsma
Created February 23, 2018 11:52
Show Gist options
  • Save StevenReitsma/2d5650eadc2e5a59fa4f749f19c9c7eb to your computer and use it in GitHub Desktop.
Save StevenReitsma/2d5650eadc2e5a59fa4f749f19c9c7eb to your computer and use it in GitHub Desktop.
Blogpost-Heineken8
def force_float_df(df):
def force_float_col(x):
try:
return x.astype(float)
except:
return pd.factorize(x)[0]
return df.apply(force_float_col)
forward_sale_cols = ['weekly_sales1', 'weekly_sales2']
drop_cols = ['date']
all_drop_cols = forward_sale_cols + drop_cols
X_pd = df_features.drop(all_drop_cols, axis=1)
X_pd_num = force_float_df(X_pd).values
y = df_features[forward_sale_cols].values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment