[BUG] Timeseries.from_dataframe() does not handle localized datetime64 index correctly anymore
See original GitHub issueThank you for keeping up the great work on darts!
Describe the bug In 0.9 with xarray backend of Timeseries, localized datetimeindex is not handled correctly (anymore). Using the toy example from another issue, you can see that plain datetimeindex is converted datetime64 in Timeseries. Once localized to UTC, the index is converted to object in Timeseries leading to downstream problems in plot(), etc.
To reproduce
df = pd.DataFrame(data={'First': [0,1,2,3,4,4.5,4,3,2,1]})
inds = [f'2021-01-{day}' for day in range(1, 11)]
df.index = pd.to_datetime(inds)
df_localized = df.copy()
df_localized.index = df.index.tz_localize('UTC')
ts = TimeSeries.from_dataframe(df)
ts_localized = TimeSeries.from_dataframe(df_localized)
Expected behaviour Localized datetimeindex is converted to datetime64 in Timeseries.
System
Python version: Python 3.9.5
darts install: pip install u8darts
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (6 by maintainers)
Top Results From Across the Web
xr.DataSet.from_dataframe / xr.DataArray.from_series ... - GitHub
DatetimeIndex which is timezone-aware and then this problem is solved because we don't maintain a separate numpy array. Am I understanding this ...
Read more >Convert pandas timezone-aware DateTimeIndex to naive ...
I want to work with timezone naive timeseries (to avoid the extra hassle with timezones, and I do not need them for the...
Read more >What's New — pandas 0.15.1 documentation
a timeseries/index localized to UTC when inserted into a Series/DataFrame will ... Bug in Index.min and max doesn't handle nan and NaT properly...
Read more >Part 5 - Working with Time Series Data | ArcGIS API for Python
A replacement for Python's native datetime , it is based on the more efficient numpy.datetime64 data type. The associated Index structure is DatetimeIndex ......
Read more >Working with Time Series | Python Data Science Handbook
This encodes a fixed-frequency interval based on numpy.datetime64 . The associated index structure is PeriodIndex . For time deltas or durations, Pandas ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@milxss you are actually right. When I ran it with darts==0.11.0 from command line, it didn’t raise the Error (in my session from above, it probably used the darts scripts from my local v==0.12.0 git repo).
We actually implemented some changes/improvements from 0.11.0 to 0.12.0 in the way how TimeSeries are created. It is very likely that this is why the output is different between the versions.
And as you said, it’s good that the new version now raises this Error.
Thanks for the investigation @dennisbader - closing the issue now.