pywr / hydra-pywr

GNU General Public License v3.0
1 stars 2 forks source link

Pandas deprecation warnings #37

Open knoxsp opened 2 weeks ago

knoxsp commented 2 weeks ago

THe error below has started to appear:

/usr/local/lib/python3.10/dist-packages/hydra_pywr-0.1-py3.10.egg/hydra_pywr/hydra_pywr_custom_module.py:61: FutureWarning: Resampling with a PeriodIndex is deprecated. Cast index to DatetimeIndex before resampling instead.
DataFrame = pd.DataFrame(np.array(self._data), index=index, columns=sc_index).resample('M').max()
pmslavin commented 2 weeks ago

I'll follow its advice of casting to DatetimeIndex as the proper solution; in the meantime, this can be suppressed with...

warnings.filterwarnings("ignore", category=FutureWarning, message=r".*Resampling with a PeriodIndex.*")  

...which also works when the warning is emitted by Pywr (from dataframe_tools.py:127).

pmslavin commented 1 week ago

The warning in the example above originates from the hydra_pywr_custom_module that is written by the user-defined rules processing routine in exporter.py:208 - i.e. it is a rule added by a user to a particular network and not part of hydra-pywr. There don't seem to be any instances of pd.DataFrame.resample() being used in hydra-pywr proper.