issues: 677307460
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
677307460 | MDU6SXNzdWU2NzczMDc0NjA= | 4337 | cftime_range does not support default cftime.datetime formatted output strings | 6063709 | closed | 0 | 5 | 2020-08-12T01:28:30Z | 2020-08-17T23:27:07Z | 2020-08-17T23:27:07Z | CONTRIBUTOR | Is your feature request related to a problem? Please describe. The
ValueError Traceback (most recent call last) <ipython-input-70-a16c1fcab8d6> in <module> 3 date = cftime.datetime(10,1,1).strftime() 4 print(date) ----> 5 xarray.cftime_range(date, periods=3, freq='Y') /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftime_offsets.py in cftime_range(start, end, periods, freq, normalize, name, closed, calendar) 963 964 if start is not None: --> 965 start = to_cftime_datetime(start, calendar) 966 start = _maybe_normalize_date(start, normalize) 967 if end is not None: /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftime_offsets.py in to_cftime_datetime(date_str_or_date, calendar) 683 "a calendar type must be provided" 684 ) --> 685 date, _ = _parse_iso8601_with_reso(get_date_type(calendar), date_str_or_date) 686 return date 687 elif isinstance(date_str_or_date, cftime.datetime): /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftimeindex.py in _parse_iso8601_with_reso(date_type, timestr) 101 102 default = date_type(1, 1, 1) --> 103 result = parse_iso8601(timestr) 104 replace = {} 105 /g/data3/hh5/public/apps/miniconda3/envs/analysis3-20.07/lib/python3.7/site-packages/xarray/coding/cftimeindex.py in parse_iso8601(datetime_string) 94 if match: 95 return match.groupdict() ---> 96 raise ValueError("no ISO-8601 match for string: %s" % datetime_string) 97 98 ValueError: no ISO-8601 match for string: 10-01-01 00:00:00 ``` Describe the solution you'd like
It would be good if Describe alternatives you've considered Specifying an ISO-8601 compatible format (using A work-around is to zero-pad manually
Additional context I think this is a relatively small addition to the codebase but would make it easier and less confusing to use the default format that is also used by the the function itself. It is easy to support as it is consistent and uniform. |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/4337/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |