from sklearn.preprocessing import StandardScaler

standard_scaler = StandardScaler(with_mean=False)
{% if pipeline.sparse_matrix %}
{% set dataframe = "pd.DataFrame.sparse.from_spmatrix" %}
{% else %}
{% set dataframe = "pd.DataFrame" %}
{% endif %}
{{ train_dataset }} = {{ dataframe }}(standard_scaler.fit_transform({{ train_dataset }}), columns={{ train_dataset }}.columns, index={{ train_dataset }}.index)
{{ test_dataset }} = {{ dataframe }}(standard_scaler.transform({{ test_dataset }}), columns={{ test_dataset }}.columns, index={{ test_dataset }}.index)
