DEPR: deprecate keep_tz keyword in DatetimeIndex.to_series · Issue #17832 · pandas-dev/pandas (original) (raw)

xref #17826

DatetimeIndex.to_series has a keep_tz keyword with a default of False (= dropping the timezone information). This stems from a time we could not store datetime tz data inside a series (with keep_tz=True, you would get an object dtyped Series of Timestamps). Nowadays this just gives a series with datetime64[ns, tz] dtype, so it makes sense to make this the default and deprecate the keyword.

Since it is an API change, ideally we first raise a warning that the behaviour will be changed (the default will change from False to True). You could then suppress this warning by passing keep_tz=True.
However, that means that we cannot directly deprecate the keyword itself, as we have to keep it for suppressing the warning / getting the future behaviour.