question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Timeseries.from_dataframe() does not handle localized datetime64 index correctly anymore

See original GitHub issue

Thank 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:closed
  • Created 2 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
dennisbadercommented, Oct 7, 2021

@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.

0reactions
hrzncommented, Oct 7, 2021

Thanks for the investigation @dennisbader - closing the issue now.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found