I have the variable time
:
>>> time = pd.to_datetime(1613260800000000000)
>>> time
Timestamp('2021-02-14 00:00:00')
time
is a timestamp
. Now I want to convert time
back to an int
value. But Timestamp
object has no attribute astype
. Running the following code:
>>>time.astype(int)
AttributeError: 'Timestamp' object has no attribute 'astype'
I know that for a column of a dataframe I can do:
>>> df['start_time'] = df['start_time'].to_timedate()
>>> df['start_time'] = df['start_time'].astype(int)
The second command assigns the type of the column to int
.
But I did not find a comprehensive source explaining what to do with individual Timestamp
argument.
How can I solve this issue?