У меня есть список объектов даты и времени. Я хочу сгруппировать их с пятиминутными интервалами. Мой код здесь:
```
count_array = [] #to simplify things, count the distructions happened in that 5-minute time range
l = len(date_array)
for timeRange in arrow.Arrow.interval('minute', start, end, 5):
count = 1
range_0 = timeRange[0].format('MM-DD-YYYY HH:mm')
range_0 = datetime.strptime(range_0, 'MM-DD-YYYY HH:mm')
range_1 = timeRange[1].format("MM-DD-YYYY HH:mm")
range_1 = datetime.strptime(range_1, "MM-DD-YYYY HH:mm")
for i in range(0, l):
if date_array[i] >= range_0 & date_array[i] <= range_1:
count = count + 1
count_array.append([timeRange[0], count])
```
Ошибка заключается в следующем:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-51-86d69bb02cdf> in <module>
5 count = 1
6 range_0 = timeRange[0].format('MM-DD-YYYY HH:mm')
----> 7 range_0 = datetime.strptime(range_0, 'MM-DD-YYYY HH:mm')
8
9 range_1 = timeRange[1].format("MM-DD-YYYY HH:mm")
~/anaconda3/lib/python3.7/_strptime.py in _strptime_datetime(cls, data_string, format)
575 """Return a class cls instance based on the input string and the
576 format string."""
--> 577 tt, fraction, gmtoff_fraction = _strptime(data_string, format)
578 tzname, gmtoff = tt[-2:]
579 args = tt[:6] + (fraction,)
~/anaconda3/lib/python3.7/_strptime.py in _strptime(data_string, format)
357 if not found:
358 raise ValueError("time data %r does not match format %r" %
--> 359 (data_string, format))
360 if len(data_string) != found.end():
361 raise ValueError("unconverted data remains: %s" %
ValueError: time data '04-06-2020 08:00' does not match format 'MM-DD-YYYY HH:mm'
Я не ошибаюсь, потому что строка "range_0 = timeRange [0] .format ('MM-DD- ГГГГ ЧЧ: мм ') "и следующая строка" range_0 = datetime.strptime (range_0,' ММ-ДД-ГГГГ ЧЧ: мм ') "имеют одинаковые строки формата. Чего мне не хватает?
Заранее спасибо.