parallel-pandas icon indicating copy to clipboard operation
parallel-pandas copied to clipboard

when rolling(30).p_apply() it says "np doesn't exist"

Open dualwieldingrogue opened this issue 10 months ago • 2 comments

so in p_apply I call this function that uses numpy or whatever 3rd party package, and it says the package doesn't exist?

dualwieldingrogue avatar Mar 05 '25 03:03 dualwieldingrogue

Сan you provide a reproducible example?

dubovikmaster avatar Mar 05 '25 08:03 dubovikmaster

I ran into this same issue I think. The problem is on windows the multi-processing behaviour creates whole new Python instance and so all global variables (including imports) are lost.

The solution is either to make the function being applied fully self contained (i.e. with its own imports etc.) or to pass the keyword argument executor=‘threads’ to the apply function to force it to use threads instead of processes.

Parakleta avatar Apr 07 '25 07:04 Parakleta