Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Subtacting times
#1
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'
Reply
#2
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)))
Reply
#3
https://docs.scipy.org/doc/numpy/referen...tract.html
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Find how many times a user played an artist and how many times disruptfwd8 1 2,595 May-04-2018, 08:32 AM
Last Post: killerrex

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020