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.

Indicate calendar type in CFTimeIndex repr

See original GitHub issue

Currently CFTimeIndex uses the default repr it inherits from pandas.Index. This just displays a potentially-truncated version of the values in the index, along with the index’s data type and length, e.g.:

CFTimeIndex([2000-01-01 00:00:00, 2000-01-02 00:00:00, 2000-01-03 00:00:00,
             2000-01-04 00:00:00, 2000-01-05 00:00:00, 2000-01-06 00:00:00,
             2000-01-07 00:00:00, 2000-01-08 00:00:00, 2000-01-09 00:00:00,
             2000-01-10 00:00:00,
             ...
             2000-12-22 00:00:00, 2000-12-23 00:00:00, 2000-12-24 00:00:00,
             2000-12-25 00:00:00, 2000-12-26 00:00:00, 2000-12-27 00:00:00,
             2000-12-28 00:00:00, 2000-12-29 00:00:00, 2000-12-30 00:00:00,
             2000-12-31 00:00:00],
            dtype='object', length=366)

It would be nice if the repr also included an indication of the calendar type of the index, since different indexes could have different calendar types. For example:

CFTimeIndex([2000-01-01 00:00:00, 2000-01-02 00:00:00, 2000-01-03 00:00:00,
             2000-01-04 00:00:00, 2000-01-05 00:00:00, 2000-01-06 00:00:00,
             2000-01-07 00:00:00, 2000-01-08 00:00:00, 2000-01-09 00:00:00,
             2000-01-10 00:00:00,
             ...
             2000-12-22 00:00:00, 2000-12-23 00:00:00, 2000-12-24 00:00:00,
             2000-12-25 00:00:00, 2000-12-26 00:00:00, 2000-12-27 00:00:00,
             2000-12-28 00:00:00, 2000-12-29 00:00:00, 2000-12-30 00:00:00,
             2000-12-31 00:00:00],
            dtype='object', length=366, calendar='proleptic_gregorian')

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
spencerkclarkcommented, Nov 20, 2020

@aaronspring I think that would be great. Indeed now that we have infer_freq it should be fairly straightforward; feel free to open a PR.

0reactions
aaronspringcommented, Nov 19, 2020

using this feature now alot. @spencerkclark what about implementing also freq into the CFTimeIndex repr?

Its hard to see the frequency by eye sometimes, I would just rely on xr.infer_freq and add to the repr str, also if freq is None/indistinguishable

Read more comments on GitHub >

github_iconTop Results From Across the Web

Weather and climate data — xarray 0.15.1 documentation
DatetimeIndex for dates from non-standard calendars commonly used in ... be used to represent times (either in indexes, as a CFTimeIndex , or...
Read more >
Ways to resample non-standard CFTimeIndex calendars (360 ...
While some models work with standard calendar, compatible with Pandas datetime , others, particularly MOHC HadGem2 ES, use 360-day CFTimeIndex .
Read more >
weather-climate.rst.txt - Xarray
_CFTimeIndex: Non-standard calendars and dates outside the Timestamp-valid ... will be used to represent times (either in indexes, as a :py:class:`~xarray.
Read more >
Weather and climate data — xarray 0.12.3 documentation
DatetimeIndex for dates from non-standard calendars commonly used in ... be used to represent times (either in indexes, as a CFTimeIndex , or...
Read more >
Python Examples of xarray.CFTimeIndex - ProgramCreek.com
``value`` for ``CFTimeIndex.shift(value, str)``. freq (str): Pandas ... kind (str): Kind of object for error message. calendar (str): calendar to set time ...
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