home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 823907100

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
823907100 MDExOlB1bGxSZXF1ZXN0NTg2MjQ0MjQ5 5006 Adapt exception handling logic in CFTimeIndex.__sub__ and __rsub__ 6628425 closed 0     0 2021-03-07T12:28:25Z 2021-03-07T13:22:06Z 2021-03-07T13:22:03Z MEMBER   0 pydata/xarray/pulls/5006

The exception that was raised in pandas when a datetime.timedelta object outside the range that could be expressed in units of nanoseconds was passed to the pandas.TimedeltaIndex constructor changed from an OverflowError to an OutOfBoundsTimedelta error in the development version of pandas. This PR adjusts our exception handling logic in CFTimeIndex.__sub__ and CFTimeIndex.__rsub__ to account for this.

  • [x] closes #4947
Previous versions of pandas: ```python >>> import pandas as pd; from datetime import timedelta >>> pd.TimedeltaIndex([timedelta(days=300 * 365)]) Traceback (most recent call last): File "pandas/_libs/tslibs/timedeltas.pyx", line 263, in pandas._libs.tslibs.timedeltas.array_to_timedelta64 TypeError: Expected unicode, got datetime.timedelta During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/spencer/Software/miniconda3/envs/xarray-tests/lib/python3.7/site-packages/pandas/core/indexes/timedeltas.py", line 157, in __new__ data, freq=freq, unit=unit, dtype=dtype, copy=copy File "/Users/spencer/Software/miniconda3/envs/xarray-tests/lib/python3.7/site-packages/pandas/core/arrays/timedeltas.py", line 216, in _from_sequence data, inferred_freq = sequence_to_td64ns(data, copy=copy, unit=unit) File "/Users/spencer/Software/miniconda3/envs/xarray-tests/lib/python3.7/site-packages/pandas/core/arrays/timedeltas.py", line 926, in sequence_to_td64ns data = objects_to_td64ns(data, unit=unit, errors=errors) File "/Users/spencer/Software/miniconda3/envs/xarray-tests/lib/python3.7/site-packages/pandas/core/arrays/timedeltas.py", line 1036, in objects_to_td64ns result = array_to_timedelta64(values, unit=unit, errors=errors) File "pandas/_libs/tslibs/timedeltas.pyx", line 268, in pandas._libs.tslibs.timedeltas.array_to_timedelta64 File "pandas/_libs/tslibs/timedeltas.pyx", line 221, in pandas._libs.tslibs.timedeltas.convert_to_timedelta64 File "pandas/_libs/tslibs/timedeltas.pyx", line 166, in pandas._libs.tslibs.timedeltas.delta_to_nanoseconds OverflowError: Python int too large to convert to C long ``` Development version of pandas: ```python >>> import pandas as pd; from datetime import timedelta >>> pd.TimedeltaIndex([timedelta(days=300 * 365)]) Traceback (most recent call last): File "pandas/_libs/tslibs/timedeltas.pyx", line 348, in pandas._libs.tslibs.timedeltas.array_to_timedelta64 TypeError: Expected unicode, got datetime.timedelta During handling of the above exception, another exception occurred: Traceback (most recent call last): File "pandas/_libs/tslibs/timedeltas.pyx", line 186, in pandas._libs.tslibs.timedeltas.delta_to_nanoseconds OverflowError: Python int too large to convert to C long The above exception was the direct cause of the following exception: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/spencer/software/pandas/pandas/core/indexes/timedeltas.py", line 161, in __new__ tdarr = TimedeltaArray._from_sequence_not_strict( File "/Users/spencer/software/pandas/pandas/core/arrays/timedeltas.py", line 270, in _from_sequence_not_strict data, inferred_freq = sequence_to_td64ns(data, copy=copy, unit=unit) File "/Users/spencer/software/pandas/pandas/core/arrays/timedeltas.py", line 970, in sequence_to_td64ns data = objects_to_td64ns(data, unit=unit, errors=errors) File "/Users/spencer/software/pandas/pandas/core/arrays/timedeltas.py", line 1079, in objects_to_td64ns result = array_to_timedelta64(values, unit=unit, errors=errors) File "pandas/_libs/tslibs/timedeltas.pyx", line 362, in pandas._libs.tslibs.timedeltas.array_to_timedelta64 File "pandas/_libs/tslibs/timedeltas.pyx", line 353, in pandas._libs.tslibs.timedeltas.array_to_timedelta64 File "pandas/_libs/tslibs/timedeltas.pyx", line 306, in pandas._libs.tslibs.timedeltas.convert_to_timedelta64 File "pandas/_libs/tslibs/timedeltas.pyx", line 189, in pandas._libs.tslibs.timedeltas.delta_to_nanoseconds pandas._libs.tslibs.conversion.OutOfBoundsTimedelta: Python int too large to convert to C long ```
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/5006/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 pull

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 0 rows from issue in issue_comments
Powered by Datasette · Queries took 0.877ms · About: xarray-datasette