I have the below array Object
which is essentially time in hours, minutes and seconds. I want to convert this object into minutes but am getting an error. The error seem to be due to different string lengths while unpacking .split
method result. Any suggestions?
df6['Chip Time']
0 16:42
1 17:34
2 18:13
3 18:32
4 19:12
...
1453 1:35:08
1454 1:43:41
1455 1:45:36
1456 1:45:40
1457 1:48:13
Name: Chip Time, Length: 1458, dtype: object
time_list = df6['Chip Time'].tolist()
# You can use a for loop to convert 'Chip Time' to minutes
time_mins = []
for i in time_list:
h,m,s = i.split(':')
math = (int(h)*3600+int(m)*60+int(s))/60
time_mins.append(math)
print(time_mins)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-52-ac7d4ab91169> in <module>
3 time_mins = []
4 for i in time_list:
----> 5 h,m,s = i.split(':')
6 math = (int(h)*3600+int(m)*60+int(s))/60
7 time_mins.append(math)
ValueError: not enough values to unpack (expected 3, got 2)