Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve formatting of reference time units under pandas 2.0.0 #7441

Merged
merged 20 commits into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f8de8f4
[test-upstream] Preserve formatting of reference time units
spencerkclark Jan 15, 2023
212adfc
Merge branch 'main' into fix-time-format
dcherian Feb 7, 2023
e180829
Use strftime to force expected date format
spencerkclark Mar 8, 2023
024360c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 8, 2023
176c6da
[test-upstream] Preserve formatting of reference time units
spencerkclark Jan 15, 2023
2c40f53
Use strftime to force expected date format
spencerkclark Mar 8, 2023
e1e827f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Mar 8, 2023
a86a1ab
[test-upstream] Remove old comment and move what's new entry to lates…
spencerkclark Mar 8, 2023
5e461a4
Merge branch 'fix-time-format' of https://github.com/spencerkclark/xa…
spencerkclark Mar 8, 2023
65169a3
Merge branch 'main' into fix-time-format
spencerkclark Mar 8, 2023
5f98835
[test-upstream] remove old comment and move what's new entry
spencerkclark Mar 8, 2023
8ce902f
Update xarray/core/formatting.py
keewis Mar 8, 2023
913b475
Merge branch 'fix-time-format' of https://github.com/spencerkclark/xa…
spencerkclark Mar 12, 2023
dcd763d
Use isoformat() now that pandas zero-pads years
spencerkclark Mar 31, 2023
4da75c3
Merge branch 'fix-time-format' of https://github.com/spencerkclark/xa…
spencerkclark Mar 31, 2023
5bfd5ab
Merge branch 'main' into fix-time-format
spencerkclark Mar 31, 2023
8751234
[test-upstream] update what's new
spencerkclark Mar 31, 2023
4370377
replace the `isoformat` separator with `" "` [test-upstream]
keewis Apr 1, 2023
8d4abcc
use the `sep` parameter to `isoformat` instead
keewis Apr 1, 2023
839881f
Update doc/whats-new.rst
keewis Apr 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ Bug fixes
By `Thomas Coleman <https://github.com/ColemanTom>`_.
- Proper plotting when passing :py:class:`~matplotlib.colors.BoundaryNorm` type argument in :py:meth:`DataArray.plot`. (:issue:`4061`, :issue:`7014`,:pull:`7553`)
By `Jelmer Veenstra <https://github.com/veenstrajelmer>`_.
- Ensure the formatting of time encoding reference dates outside the range of
nanosecond-precision datetimes remains the same under pandas version 2.0.0
(:issue:`7420`, :pull:`7441`).
By `Justus Magin <https://github.com/keewis>`_ and
`Spencer Clark <https://github.com/spencerkclark>`_.


Documentation
~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions xarray/core/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def calc_max_rows_last(max_rows: int) -> int:

def format_timestamp(t):
"""Cast given object to a Timestamp and return a nicely formatted string"""
# Timestamp is only valid for 1678 to 2262
try:
datetime_str = str(pd.Timestamp(t))
timestamp = pd.Timestamp(t)
datetime_str = timestamp.isoformat(sep=" ")
except OutOfBoundsDatetime:
datetime_str = str(t)

Expand Down