0

I am currently trying to reproduce this: convert numeric sas date to datetime in Pandas , but get the following error:

"Python int too large to convert to C long"

Here and example of my dates:

    0    1.416096e+09
    1    1.427069e+09
    2    1.433635e+09
    3    1.428624e+09
    4    1.433117e+09
Name: dates, dtype: float64

Any ideas?

user27074
  • 627
  • 1
  • 6
  • 20

1 Answers1

2

Here is a little hacky solution. If the date column is called 'date', try

df['date'] = pd.to_datetime(df['date'] - 315619200, unit = 's')

Here 315619200 is the number of seconds between Jan 1 1960 and Jan 1 1970.

You get

0   2004-11-15 00:00:00
1   2005-03-22 00:03:20
2   2005-06-05 23:56:40
3   2005-04-09 00:00:00
4   2005-05-31 00:03:20
Vaishali
  • 37,545
  • 5
  • 58
  • 86