type_caster is not working for converting pandas.Timestamp to custom C++ chrono type #4469
Unanswered
steve-lorimer
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a python API that uses
asyncio
to download a large quantity of data from a 3rd party vendor and delivers it to the caller in chunks:I want to wrap this API and expose it to C++. My idea is to pass a
std::function
bound to a callback, and call this for each chunk of dataThe
time
produced in the python API is apandas.Timestamp
.My company has a custom time class,
chrono::Time
, which stores time as nanoseconds since the epoch.To enable conversion from
pandas.Timestamp
tochrono::Time
, I have added the following specialisation:This, afaik, should allow me to do the following from C++:
The call to
download
fails, however, with the following exception:The above specialisation for
chrono::Time
works when passing from C++ to python (the type received in python ispandas.Timestamp
), but it doesn't seem to be working for passingpandas.Timestamp
from python to C++.How can I enable the automatic conversion of a
pandas.Timestamp
to my customchrono::Time
class when called from an embedded python script?Beta Was this translation helpful? Give feedback.
All reactions