Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

min/max for 2 arguments #2

Closed
aminnj opened this issue Jan 20, 2021 · 1 comment
Closed

min/max for 2 arguments #2

aminnj opened this issue Jan 20, 2021 · 1 comment

Comments

@aminnj
Copy link
Owner

aminnj commented Jan 20, 2021

import numpy as np
import pandas as pd
import pdroot
np.random.seed(42)
df = pd.DataFrame(np.random.normal(0,1,(100,4)), columns=list("abcd"))
df.draw_to_array("min(a,b)")

gives

~/sandbox/dev/pdroot/pdroot/draw.py in tree_draw_to_array(df, varexp, sel)
     49     dims = []
     50     for expr in varexp_exprs:
---> 51         vals = eval(expr)
     52 
     53         if sel:

~/sandbox/dev/pdroot/pdroot/draw.py in <module>

TypeError: min() got multiple values for argument 'axis'

though regular pandas df.eval("min(a,b)") says min isn't a supported function, so there's technically no loss here. However, df.draw_to_array("np.minimum(a,b)") actually works (while pandas eval doesn't recognize np), so maybe if there are two arguments to min, we use np.minimum instead of ak.min(..., axis=1) [1]?

[1]

from pdroot.parse import to_ak_expr
to_ak_expr("min(a,b)")
# ak.min(a, b, axis=-1)
@aminnj
Copy link
Owner Author

aminnj commented Jan 20, 2021

min/max added in by d1352e0

@aminnj aminnj closed this as completed Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant