Skip to content

Datasets: finish pandas 2 freq alias migration in _tsf_reader#3291

Open
shaun0927 wants to merge 1 commit intoawslabs:devfrom
shaun0927:fix/tsf-reader-freq
Open

Datasets: finish pandas 2 freq alias migration in _tsf_reader#3291
shaun0927 wants to merge 1 commit intoawslabs:devfrom
shaun0927:fix/tsf-reader-freq

Conversation

@shaun0927
Copy link
Copy Markdown

Issue #, if available: follow-up to #3232

Description of changes:

#3232 replaced a few of the pandas offset aliases that became deprecated in pandas 2.2 (e.g. H → h, T → min), but _tsf_reader.py still emits the remaining deprecated ones: S, M, Q, Y. On pandas 2.3 they produce FutureWarnings, and they are scheduled to stop working in pandas 3.0.

>>> import pandas as pd; pd.__version__
'2.3.3'
>>> from gluonts.dataset.repository._tsf_reader import BASE_FREQ_TO_PANDAS_OFFSET as M
>>> M["monthly"], M["quarterly"], M["yearly"], M["seconds"]
('M', 'Q', 'Y', 'S')
>>> pd.tseries.frequencies.to_offset("30S")
FutureWarning: 'S' is deprecated and will be removed in a future version, please use 's' instead.
>>> pd.tseries.frequencies.to_offset("1M")
FutureWarning: 'M' is deprecated and will be removed in a future version, please use 'ME' instead.

The mapping is the single source used by frequency_converter, which is called by datasets.get_dataset_tsf_datasets.py when loading any dataset derived from forecastingdata.org (tourism_monthly, tourism_quarterly, tourism_yearly, cif_2016, m5, etc.).

Changes:

  • src/gluonts/dataset/repository/_tsf_reader.py: migrate the four remaining aliases to the pandas-2-compatible spellings (s, ME, QE, YE).
  • test/dataset/test_tsf_reader.py: update the expected values in test_frequency_converter accordingly, pinning the new contract.
test/dataset/test_tsf_reader.py ...............                          [100%]
============================== 15 passed in 0.13s ==============================

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Please tag this pr with at least one of these labels to make our release process faster: BREAKING, new feature, bug fix, other change, dev setup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant