Closed ianhsiehbcn closed 1 year ago
I'm curious why using the data_to_dict
function doesn't work? In theory it should convert the numpy.recarray
into a dict mapping strings to simple numpy.ndarray
objects that reticulate should be able to deal with. Mind trying to access
pyblp$data_to_dict(simulation_results$product_data)
or even something like
pandas$DataFrame(pyblp$data_to_dict(simulation_results$product_data))
after activating pandas with reticulate and letting me know if either of these works?
Unfortunately, both functions led to the error message quoted above.
Oh right, it should be the same solution as https://github.com/jeffgortmaker/pyblp/issues/106#issuecomment-1039597092: using convert = FALSE
and py_to_r
. Let me know if that works.
I think the above will probably fix your issue, so I'm closing this issue for now, but please do keep commenting/re-open the issue if you're still having problems!
Hi Jeff!
We are trying to run a counterfactual simulation using the PyBLP package in R with
reticulate
. We use thesimulation$replace_endogenous()
command to compute the new equilibrium prices and shares, but when we try to access the new data, stored insimulation_results$product_data
, we are not able to do it because R cannot open the object, which is anumpy.recarray
object. The error message we get is the following one:We have tried several solutions suggested in the pyblp documentation, such as using the
pyblp$data_to_dict()
function, or the simulations results$to_dict()
function, but none of them has worked so far. We would appreciate some help on how to access this object from R, and more generally, some guidance on how to convert recarray objects into some other numpy object which could be opened in R.Thanks for building this amazing package!!