Repository: awslabs/gluonts

Issue #958: pandas-offsets stopped being hashable
Created: 2020-07-30T08:19:35Z
In Pandas 1.1 the freq component of the time-stamps that we use have stopped being hashable, which means, they cannot be used as keys in dictionaries. We use this in different locations in our code base.
We now have two options:

open an issue with pandas, requesting that the old behaviour is restored
change our code to not make use of this feauture

Duplicate issue #959: New pandas version not compatible with gluonts
Created: 2020-07-31T03:32:58Z
Description
I re-installed the gluonts version 0.5.0 but got a TypeError. However, when I changed the pandas version back to 1.0.1, the conflict was solved.
To Reproduce
predictor = estimator.train(dataset.train) this line from the https://gluon-ts.mxnet.io/examples/basic_forecasting_tutorial/tutorial.html tutorial raised a type error.
import mxnet as mx
from mxnet import gluon
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import json
from gluonts.dataset.repository.datasets import get_dataset, dataset_recipes
from gluonts.dataset.util import to_pandas
from gluonts.model.simple_feedforward import SimpleFeedForwardEstimator
from gluonts.trainer import Trainer
from gluonts.evaluation.backtest import make_evaluation_predictions
from gluonts.evaluation import Evaluator


dataset = get_dataset("electricity", regenerate=False)
entry = next(iter(dataset.train))
train_series = to_pandas(entry)
entry = next(iter(dataset.test))
test_series = to_pandas(entry)

estimator = SimpleFeedForwardEstimator(
    num_hidden_dimensions=[10],
    prediction_length=dataset.metadata.prediction_length,
    context_length=100,
    freq=dataset.metadata.freq,
    trainer=Trainer(ctx="cpu",
                    epochs=5,
                    learning_rate=1e-3,
                    num_batches_per_epoch=100
                   )
)

predictor = estimator.train(dataset.train)```

## Error message or code output
(Paste the complete error message, including stack trace, or the undesired output that the above snippet produces.)

```Traceback (most recent call last):
  File "/Users/caixiyan/Desktop/amazon/auto/original.py", line 33, in <module>
    predictor = estimator.train(dataset.train)
  File "/Users/caixiyan/Library/Python/3.8/lib/python/site-packages/gluonts/model/estimator.py", line 251, in train
    return self.train_model(
  File "/Users/caixiyan/Library/Python/3.8/lib/python/site-packages/gluonts/model/estimator.py", line 227, in train_model
    self.trainer(
  File "/Users/caixiyan/Library/Python/3.8/lib/python/site-packages/gluonts/trainer/_base.py", line 303, in __call__
    epoch_loss = loop(epoch_no, train_iter)
  File "/Users/caixiyan/Library/Python/3.8/lib/python/site-packages/gluonts/trainer/_base.py", line 231, in loop
    for batch_no, data_entry in enumerate(it, start=1):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tqdm/std.py", line 1108, in __iter__
    for obj in iterable:
  File "/Users/caixiyan/Library/Python/3.8/lib/python/site-packages/gluonts/dataset/loader.py", line 181, in __iter__
    for batch in self._it:
  File "/Users/caixiyan/Library/Python/3.8/lib/python/site-packages/gluonts/dataset/parallelized_loader.py", line 634, in same_process_iter
    batch_samples = list(
  File "/Users/caixiyan/Library/Python/3.8/lib/python/site-packages/gluonts/dataset/parallelized_loader.py", line 242, in _sequential_sample_generator
    yield from transformation(
  File "/Users/caixiyan/Library/Python/3.8/lib/python/site-packages/gluonts/transform/_base.py", line 150, in __call__
    raise e
  File "/Users/caixiyan/Library/Python/3.8/lib/python/site-packages/gluonts/transform/_base.py", line 144, in __call__
    for result in self.flatmap_transform(
  File "/Users/caixiyan/Library/Python/3.8/lib/python/site-packages/gluonts/transform/split.py", line 242, in flatmap_transform
    d[self.forecast_start_field] = shift_timestamp(
  File "/Users/caixiyan/Library/Python/3.8/lib/python/site-packages/gluonts/transform/split.py", line 36, in shift_timestamp
    return _shift_timestamp_helper(ts, ts.freq, offset)
TypeError: unhashable type: 'pandas._libs.tslibs.offsets.Hour'
Environment

Operating system: OSX
Python version: 3.8
GluonTS version: 0.5.0
MXNet version: 1.6.0

(Add as much information about your environment as possible, e.g. dependencies versions.)

Closing comment (2020-07-31T10:04:41Z): Thanks for raising the issue.
It's a duplicate of #958.