gluonts
gluonts copied to clipboard
bug: unexpected in-place modification of dataframe index inside class method
hey! just a heads up, these lines:
https://github.com/awslabs/gluonts/blob/7bb6800a149a6caac7ec1725132c73bf06a57e2b/src/gluonts/dataset/pandas.py#L284-L286
are modifying the dataframe in-place by setting its index. since this happens inside a class method, it might be unexpected for whoever passed the dataframe, especially if they rely on its original structure later. in my case, i iterate over the same dataframe later on, but after calling the method (second print), the index has been altered, which breaks assumptions about its structure.
to avoid side effects, we probably want to work on a copy instead (or at least document that this changes the input). otherwise, it can silently break downstream code.