{% if columns %}
import numpy as np
from sklearn.impute import SimpleImputer

STRING_COLS_WITH_MISSING_VALUES = {{ columns }}
simple_imputer = SimpleImputer(missing_values=np.nan, strategy='most_frequent')
{{ train_dataset }}[STRING_COLS_WITH_MISSING_VALUES] = simple_imputer.fit_transform({{ train_dataset }}[STRING_COLS_WITH_MISSING_VALUES])

with open('simpleimputer-string.pkl', 'wb') as f:
    pickle.dump(simple_imputer, f)
{% endif %}
{% if cols_almost_missing_string %}
STRING_ALMOST_MISSING_COLS = {{ cols_almost_missing_string }}
{{ train_dataset }}[STRING_ALMOST_MISSING_COLS] = {{ train_dataset }}[STRING_ALMOST_MISSING_COLS].astype(str)
{{ train_dataset }}[STRING_ALMOST_MISSING_COLS] = {{ train_dataset }}[STRING_ALMOST_MISSING_COLS].fillna('')
{% endif %}