Click here to Skip to main content
15,564,017 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
https://1drv.ms/u/s!AqOToJXfujDolGP2oP9gTlpfc902?e=NXDgbT

Basically says it in the title. I want the type <class'pandas._libs.tslibs.timestamps.timestamp'> to change to <class 'int'="">. However I want the values 15478 and 16216 to stay the same.

What I have tried:

Simply using int() doens't work unfortunately and gives the following error message:

TypeError: int() argument must be a string, a bytes-like object or a number, not 'Timestamp'
Posted
Comments
Richard MacCutchan 18-Apr-22 14:27pm    
The error message says it all, you cannot convert a TimeStamp to an int. However, you can extract the time as a number of minutes, seconds etc. It all depends what you are trying to do with the information.
Zomaar een kijker 18-Apr-22 15:34pm    
The end goal is to be able use these numbers so the 15478 and 16216 in "slicing" another dataset. However I can't simply put these numbers in because I get the following error:

TypeError: slice indices must be integers or None or have an __index__ method

Is there any other way to make it so I can use these numbers in slicing?
Richard MacCutchan 18-Apr-22 15:46pm    
You have not explained what these numbers are and how they relate to a TimeStamp.
Zomaar een kijker 18-Apr-22 18:04pm    
So the code and the dataset are in the link provided in the top of my first comment. The number is basically indexed from a list a list of dates, I think the reason it might be specifically this type is because I searched for this using BMonthEnd which gives you the end date of a business month. The goal is to just use that number on a different list.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900