Error encountered in Hazards/SARChangeDetectionMethods_From_Prepared_Data_Stack.ipynb
testern opened this issue · 1 comments
testern commented
I was working through the Hazards/SARChangeDetectionMethods_From_Prepared_Data_Stack.ipynb notebook, which is based on data from the Exercise4A-SARChangeDetectionMethods.ipynb notebook.
At step 4. Create a Pandas Time Index and Display the VRT Band Dates, I encountered the following while running cell 14:
Create an index of timedelta64 data with Pandas:
tindex = pd.DatetimeIndex(dates)
tindex = pd.DatetimeIndex(dates)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~/.local/envs/rtc_analysis/lib/python3.9/site-packages/pandas/core/arrays/datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object)
2084 try:
-> 2085 values, tz_parsed = conversion.datetime_to_datetime64(data)
2086 # If tzaware, these values represent unix timestamps, so we
pandas/_libs/tslibs/conversion.pyx in pandas._libs.tslibs.conversion.datetime_to_datetime64()
TypeError: Unrecognized value type: <class 'str'>
During handling of the above exception, another exception occurred:
ParserError Traceback (most recent call last)
<ipython-input-14-3b54fb0f6ce4> in <module>
----> 1 tindex = pd.DatetimeIndex(dates)
~/.local/envs/rtc_analysis/lib/python3.9/site-packages/pandas/core/indexes/datetimes.py in __new__(cls, data, freq, tz, normalize, closed, ambiguous, dayfirst, yearfirst, dtype, copy, name)
305 name = maybe_extract_name(name, data, cls)
306
--> 307 dtarr = DatetimeArray._from_sequence_not_strict(
308 data,
309 dtype=dtype,
~/.local/envs/rtc_analysis/lib/python3.9/site-packages/pandas/core/arrays/datetimes.py in _from_sequence_not_strict(cls, data, dtype, copy, tz, freq, dayfirst, yearfirst, ambiguous)
324 freq, freq_infer = dtl.maybe_infer_freq(freq)
325
--> 326 subarr, tz, inferred_freq = sequence_to_dt64ns(
327 data,
328 dtype=dtype,
~/.local/envs/rtc_analysis/lib/python3.9/site-packages/pandas/core/arrays/datetimes.py in sequence_to_dt64ns(data, dtype, copy, tz, dayfirst, yearfirst, ambiguous)
1971 # data comes back here as either i8 to denote UTC timestamps
1972 # or M8[ns] to denote wall times
-> 1973 data, inferred_tz = objects_to_datetime64ns(
1974 data, dayfirst=dayfirst, yearfirst=yearfirst
1975 )
~/.local/envs/rtc_analysis/lib/python3.9/site-packages/pandas/core/arrays/datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object)
2088 return values.view("i8"), tz_parsed
2089 except (ValueError, TypeError):
-> 2090 raise e
2091
2092 if tz_parsed is not None:
~/.local/envs/rtc_analysis/lib/python3.9/site-packages/pandas/core/arrays/datetimes.py in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object)
2073
2074 try:
-> 2075 result, tz_parsed = tslib.array_to_datetime(
2076 data,
2077 errors=errors,
pandas/_libs/tslib.pyx in pandas._libs.tslib.array_to_datetime()
pandas/_libs/tslib.pyx in pandas._libs.tslib.array_to_datetime()
pandas/_libs/tslib.pyx in pandas._libs.tslib.array_to_datetime_object()
pandas/_libs/tslib.pyx in pandas._libs.tslib.array_to_datetime_object()
pandas/_libs/tslibs/parsing.pyx in pandas._libs.tslibs.parsing.parse_datetime_string()
~/.local/envs/rtc_analysis/lib/python3.9/site-packages/dateutil/parser/_parser.py in parse(timestr, parserinfo, **kwargs)
1372 return parser(parserinfo).parse(timestr, **kwargs)
1373 else:
-> 1374 return DEFAULTPARSER.parse(timestr, **kwargs)
1375
1376
~/.local/envs/rtc_analysis/lib/python3.9/site-packages/dateutil/parser/_parser.py in parse(self, timestr, default, ignoretz, tzinfos, **kwargs)
647
648 if res is None:
--> 649 raise ParserError("Unknown string format: %s", timestr)
650
651 if len(res) == 0:
ParserError: Unknown string format: _2018010
Alex-Lewandowski commented
Thanks for finding that @testern! It was a bad date parsing regex. Fixed and pushed to the conda_envs branch