Python Forum
Subtacting times - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: Subtacting times (/thread-17308.html)



Subtacting times - Confused - Apr-06-2019

2. Write your code to calculate an array called **opening_duration_list**
that stores the opening duration of all medicare offices.
Store the array as a numpy array.
Print the first 10 entries in the array.

import numpy as np
import datetime as datetime
x= np.array(data['Close'],dtype=datetime.time)
y= np.array(data['Open'], dtype=datetime.time)
print((x-y))
Error:
ipython-input-76-c1a1ba0f9f3c> in <module> 3 x= np.array(data['Close'],dtype=datetime.time) 4 y= np.array(data['Open'], dtype=datetime.time) ----> 5 print((x-y)) 6 7 TypeError: unsupported operand type(s) for -: 'str' and 'str'



RE: Subtacting times - ahamsy - Apr-10-2019

import numpy as np
import datetime as datetime
x= np.array(data['Close'],dtype=datetime.time)
y= np.array(data['Open'], dtype=datetime.time)
print((int(x)-int(y)))


RE: Subtacting times - nilamo - Apr-10-2019

https://docs.scipy.org/doc/numpy/reference/generated/numpy.subtract.html