Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Pandas datetime
#1
I have some data which I read in pandas like this
data = pd.read_table('filename.txt', sep='  ',index_col=None,engine='python')
The first column is date time in the format 120631135243(YYMMDDhhmmss).
I would like to convert this to a proper date time in the format YY MM DD hh:mm:ss

I tried this
date1=datetime.datetime.fromtimestamp(data2/1e3)
where data2 is data.iloc[1:,0], the first column of the file
but resulted in this error
Error:
TypeError                                 Traceback (most recent call last) <ipython-input-74-a215186a1d9c> in <module>() ----> 1 date1=datetime.datetime.fromtimestamp(data2/1e3) /home/nuncio/anaconda2/lib/python2.7/site-packages/pandas/core/series.pyc in wrapper(self)     78             return converter(self.iloc[0])     79         raise TypeError("cannot convert the series to " ---> 80                         "{0}".format(str(converter)))     81     82     return wrapper TypeError: cannot convert the series to <type 'float'>
Any suggestions
thankyou
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,831 Jul-05-2021, 06:16 PM
Last Post: eddywinch82
  itertuples, datetime, pandas, groupby, in range karlito 0 2,515 Nov-29-2019, 11:35 AM
Last Post: karlito
  itertuples, new column, datetime, pandas karlito 6 4,080 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