- #TODO: add other filling methods like linear interpolation
- self._dataframe = self._dataframe.fillna(method='ffill')
- self._dataframe = self._dataframe.fillna(method='bfill')
+
+ if self._config['PREPROCESSING']['fill_method'] == 'propagate':
+ self._dataframe = self._dataframe.fillna(method='ffill')
+ elif self._config['PREPROCESSING']['fill_method'] == 'linear':
+ self._dataframe = self._dataframe.interpolate()
+ elif self._config['PREPROCESSING']['fill_method'] == 'spline':
+ self._dataframe = self._dataframe.interpolate(method='spline',
+ order=self._config['PREPROCESSING'].getint('order'))
+
+ # 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')
+