I used np.subtract () where I got the following error.
Cannot convert input [(0, slice(None, None, None))] of type to Timestamp
stock_open=panel_data['Open']
stock_close=panel_data['Close']
row,col=stock_close.shape
movements = np.zeros([row, col])
for i in range(0, row):
movements[i,:] = np.subtract(stock_close[i,:], stock_open[i,:])
The below line in my code:
movements[i,:] = np.subtract(stock_close[i,:], stock_open[i,:])
gives me the following error.
TypeError: Cannot convert input [(0, slice(None, None, None))] of type to Timestamp
use the below line
np.subtract(stock_close.values[i,:], stock_open.values[i,:])
or if you're looking for an even better way to do it :
stock_close.values[i,:] - stock_open.values[i,:]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With