Trying to implement the model of time series predicting in python but facing with issues with datetime data.
So I have a dataframe 'df' with two columns of datetime and float types:
Then I try to build an array using values method. But smth strange happens and it displays the date in strange format with timestamps and time:
And basically because of it, I can not implement the model receiving the following messages for example:"Cannot add integral value to Timestamp without freq."
So what seems to be the problem and how can it be solved?
you can convert your integer into a
timedelta
, and do the calculations as you did before:It's complicated.
First of all, when creating a
numpy
array, all types will be the same. However,datetime64
is not the same asint
. So we'll have to resolve that, and we will.Second, you tried to do this with
df.values
. Which makes sense, however, what happens is thatpandas
makes the wholedf
intodtype=object
then into anobject
array. The problem with that is thatTimestamps
get left asTimestamps
which is getting in your way.So I'd convert them on my own like this
We can always convert the first column of a back like this