I am importing a CSV into a pandas dataframe. One column contains an 18 digit LDAP timestamp. I am trying to convert this timestamp however it appears that it is being rounded causing incorrect calculation.
data.csv:
Event ID,Clock-Time,ProcessID
10,133081599160584000,2824,44
10,133081599160584000,2824,84
10,133081599160667000,2824,44
10,133081599160667000,2824,92
10,133081599160667000,2824,116
10,133081599160667000,2824,132
script.py
#!/usr/bin/python
from datetime import datetime, timedelta
import pandas
pandas.set_option('display.max_colwidth', None)
pandas.set_option('display.float_format','{:.0f}'.format)
pandas.set_option('display.precision', 20)
in_csv = "data.csv"
df = pandas.read_csv(in_csv,sep=',',header=0, float_precision='high')
print(df.dtypes)
print(df)
# convert win32 timestamp to unix timestamp
df['Clock-Time'] = df['Clock-Time'].apply(lambda timestamp: datetime(1601, 1, 1) + timedelta(seconds=(timestamp/10000000)))
print(df)
output:
Event ID int64
Clock-Time float64
ProcessID int64
Size int64
dtype: object
Event ID Clock-Time ProcessID Size
0 10 133082000000000000 2824 44
1 10 133082000000000000 2824 84
2 10 133082000000000000 2824 44
3 10 133082000000000000 2824 92
4 10 133082000000000000 2824 116
5 10 133082000000000000 2824 132
Event ID Clock-Time ProcessID Size
0 10 2022-09-21 02:13:20 2824 44
1 10 2022-09-21 02:13:20 2824 84
2 10 2022-09-21 02:13:20 2824 44
3 10 2022-09-21 02:13:20 2824 92
4 10 2022-09-21 02:13:20 2824 116
5 10 2022-09-21 02:13:20 2824 132
How can I get pandas to respect the full value so I can get the accurate timestamp?
