I would like to ask a question abou the error I am getting here. I am trying to create a new column that intiate a position if the price of tomorrow is predicted higher than today using the following code. it is giving me the error:
TypeError: Addition/subtraction of integers and integer-arrays with Timestamp is no longer supported. Instead of adding/subtracting
n
, usen * obj.freq
new= pd.DataFrame(index=x_valid.index)
new['Shares'] = [1 if x_valid[i+1] > x_valid[i] else 0 for i in new.index]
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-92-5e7800e6d5ce> in <module>()
2 new= pd.DataFrame(index=x_valid.index)
3
----> 4 new['Shares'] = [1 if x_valid[i+1]>x_valid[i] else 0 for i in new.index]
<ipython-input-92-5e7800e6d5ce> in <listcomp>(.0)
2 new= pd.DataFrame(index=x_valid.index)
3
----> 4 new['Shares'] = [1 if x_valid[i+1]>x_valid[i] else 0 for i in new.index]
pandas/_libs/tslibs/timestamps.pyx in pandas._libs.tslibs.timestamps._Timestamp.__add__()
TypeError: Addition/subtraction of integers and integer-arrays with Timestamp is no longer supported. Instead of adding/subtracting `n`, use `n * obj.freq`
Any insights would be much appreciated
source https://stackoverflow.com/questions/67706244/timestamp-is-no-longer-supported-error-when-creating-a-new-column
Comments
Post a Comment