monkey_patch
Functions:
Name | Description |
---|---|
patch_dataframe_libraries |
Applies two patches to the DataFrame and Series classes of both pandas and polars. |
patch_dataframe_libraries()
Applies two patches to the DataFrame and Series classes of both pandas and polars.
1) Patches arithmetic operators (e.g. __add__
) such that operations between DataFrames/Series and Expressionable
s
are not supported (i.e. return NotImplemented
). This leads Python to try the reverse operation (e.g. __radd__
)
which is supported by the Expressionable
class.
2) Adds a to_expr
method to DataFrame/Series that allows them to be converted to an Expression
object.
Series become dataframes and dataframes become expressions where everything but the last column are treated as dimensions.