+ logger.info("Filling NaN numerical values in the feature dataframe")
+ # We interpolate (linearly or with splines) only numerical columns
+ numerical_columns = [k for k in self._features if self._features[k]['type'] == 1
+ or (self._features[k]['type'] == 3 and self._features[k]['numerical'])]
+ # The interpolation
+ if self._config['PREPROCESSING']['fill_method'] == 'propagate':
+ self._dataframe[numerical_columns] =\
+ self._dataframe[numerical_columns].fillna(method='ffill')
+ elif self._config['PREPROCESSING']['fill_method'] == 'linear':
+ self._dataframe[numerical_columns] =\
+ self._dataframe[numerical_columns].interpolate()
+ elif self._config['PREPROCESSING']['fill_method'] == 'spline':
+ self._dataframe[numerical_columns] =\
+ self._dataframe[numerical_columns].interpolate(method='spline',
+ order=self._config['PREPROCESSING'].getint('order'))
+
+ # For the categorical columns, NaN values are filled by duplicating
+ # the last known value (forward fill method)
+ logger.info("Filling NaN categorical values in the feature dataframe")
+ categorical_columns = [k for k in self._features if self._features[k]['type'] == 2
+ or (self._features[k]['type'] == 3 and not self._features[k]['numerical'])]
+ self._dataframe[categorical_columns] =\
+ self._dataframe[categorical_columns].fillna(method='ffill')
+
+ # Uncomment this line to fill NaN values at the beginning of the
+ # dataframe. This may not be a good idea, especially for features
+ # that are available only for recent years, e.g., air quality
+ #self._dataframe = self._dataframe.fillna(method='bfill')
+
+ # Dropping rows that are not related to our datetime window (start/
+ # step / end)