Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Pandas datetime
#4
(Jan-06-2017, 04:48 PM)ichabod801 Wrote: datetime.fromtimestamp takes as a parameter the number of seconds since the epoch. That's not what you have, you have the digits of the various parts of the date/time concatenated together to make an integer.

I would break apart the number you have and feed it into the standard datetime constructor, which takes parameters like year, month, day, hour, minutes, and seconds. You could do that either with mod (%) and integer division (//), or you could make the number a string, use slices to get the parts you want, and convert them back into integers. My guess is that the number you have is already a string, and that's why you're getting a conversion error instead of an incorrect date.

THanks  Its working
Reply


Messages In This Thread
Python Pandas datetime - by nuncio - Jan-06-2017, 05:14 AM
RE: Python Pandas datetime - by ichabod801 - Jan-06-2017, 04:48 PM
RE: Python Pandas datetime - by nuncio - Jan-08-2017, 09:34 AM
RE: Python Pandas datetime - by snippsat - Jan-06-2017, 05:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pandas datetime: add timedelta ju21878436312 3 6,784 Jul-05-2021, 06:16 PM
Last Post: eddywinch82
  itertuples, datetime, pandas, groupby, in range karlito 0 2,486 Nov-29-2019, 11:35 AM
Last Post: karlito
  itertuples, new column, datetime, pandas karlito 6 4,006 Nov-29-2019, 11:07 AM
Last Post: karlito

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020