Pandas: Check If Value Is Epoch Time Using Python
I have a script that reads a csv like this: df = pd.read_csv('short.csv', parse_dates=['date']) The 'date' column could have any type of date formats and that works fine because I
Solution 1:
I think you can first omit parsing datetime
in read_csv
and check epoch datetime
by to_numeric
with notnull
:
df = pd.read_csv("short.csv")
print df
date
0 1368431150
1 1368431149
2 2015-05-18
print pd.to_numeric(df.date, errors='coerce').notnull()
0 True
1 True
2 False
Name: date, dtype: bool
Post a Comment for "Pandas: Check If Value Is Epoch Time Using Python"