1

I am formatting pandas dataframe timestamp column to unix timestamp as follows

from datetime import datetime

df["col_in_unix"] = df["example_col"].\
                        apply(lambda x: datetime.strptime(x, '%Y-%m-%d %H:%M:%S.%f').timestamp())

And when running this on my computer I get from a timestamp

datetime.strptime("2020-12-09 13:27:48.172793", '%Y-%m-%d %H:%M:%S.%f').timestamp()

1607513268.172793

but when I run the code in different windows pc I sometimes get answer

1607513268.17

And this happens to all timestamps in the dataframe column, what gives? I have also made .exe file from the script with Pyinstaller and still the same problem

sophros
  • 14,672
  • 11
  • 46
  • 75
eemilk
  • 1,375
  • 13
  • 17

1 Answers1

1

I am wondering if this is not related to either:

  1. Differences in system time resolution due to different hardware / drivers, etc.
  2. precision setting for pandas and/or the dataframe
  3. Similar issue described for Windows 32b vs. 64b in C# (you are likely to observe a similar problem between 32b and 64b versions of Python).
  4. Some other factor
sophros
  • 14,672
  • 11
  • 46
  • 75
  • 1
    Thanks for the input, it was unrelated issue to my script. Apparently where I fetch the data had problems and is now fixed :) – eemilk Dec 18 '20 at 06:00
  • Do you mean different "disk speeds" so that the data reading took different times? – sophros Dec 18 '20 at 06:12