Polars: The enum variant Expr::AnonymousFunction cannot be serialized
Any usage of value_counts fails with this error:
rdf.select(pl.col("gender").value_counts()).collect().fetch()
Error: ValueError: Error("the enum variant Expr::AnonymousFunction cannot be serialized", line: 0, column: 0)
As @lyie28 told me, this is also the case for these operators:
- abs()
- unique_counts()
- is_finite()
- is_first()
- is_inifinite()
Additional context from @lyie28:
I spoke to Lucas about this and it seems this is probably because some Polars functions were implemented using user defined function with lambdas which we can't support, whereas they have updated many of their functions to have a different kind of implementation which we can support. So it might be that with time, Polars updates some of these functions to something we can support anyway, but otherwise, we would need to slowly implement them one by one, probably as torch script implementations (or occasionally it may be possible by combining available Polars methods- like unique().count() instead of unique_counts()). I am working on some other stuff now but might come back to this
Feel free to postpone, or close this issue if this is deemed infeasible – although in this case a better error message would probably be welcome
I suggest we improve error reporting as Charles suggested