pythonpandasnumexpr

Unable to subtract datetime64 using DataFrame.eval()


Given a DataFrame with a couple of timestamps:

In [88]: df.dtypes
Out[88]:
Time             datetime64[ns]
uniqstime        datetime64[ns]
dtype: object

If I call eval(), I get a type error:

In [91]: df.eval('since = Time - uniqstime')
...

ValueError: unkown type timedelta64[ns]

(By the way, "unknown" is misspelled in the error message.)

But I can use Python notation:

In [92]: df['since'] = df.Time - df.uniqstime

Is there an issue with assigning a timedelta in numexpr?


Solution

  • This is already was issue on github (albeit closed), see here: https://github.com/pydata/pandas/issues/5007

    It is unsupported at this time. However, their is no real advantage ATM as these computations are done in python space anyhow.