Skip to content

COMPAT: numpy compat with array methods in >= 1.7 #4435

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

Closed
jreback opened this issue Aug 2, 2013 · 0 comments · Fixed by #5034
Closed

COMPAT: numpy compat with array methods in >= 1.7 #4435

jreback opened this issue Aug 2, 2013 · 0 comments · Fixed by #5034
Assignees
Labels
API Design Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Aug 2, 2013

This is and API change in numpy >= 1.7, but need to work around. Numpy now
looks at the structure for a prod method (if the function is not operating on a numpy array), if it has one, then it passes the arguments
axis,dtype,out, currently these types of methods only aceept axis, need to accept dtype,out as dummy arguments for compat

affects mean,sum,prod,std...prob others

In [1]: df = DataFrame(randn(10,2))

In [2]: np.prod(df)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-99feb18ea783> in <module>()
----> 1 np.prod(df)

/usr/local/lib/python2.7/site-packages/numpy/core/fromnumeric.pyc in prod(a, axis, dtype, out, keepdims)
   2111             return _methods._prod(a, axis=axis, dtype=dtype,
   2112                                 out=out, keepdims=keepdims)
-> 2113         return prod(axis=axis, dtype=dtype, out=out)
   2114     else:
   2115         return _methods._prod(a, axis=axis, dtype=dtype,

TypeError: prod() got an unexpected keyword argument 'dtype'

In [3]: np.prod(df.values)
Out[3]: -2.2566177751865827e-07

In [4]: np.prod(df.values,axis=1)
Out[4]: 
array([-0.00912739,  0.00569453,  0.58508784,  0.87462665, -0.32556754,
        0.12015118,  1.01860104, -0.15380337, -0.54518287, -2.5393832 ])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Dtype Conversions Unexpected or buggy dtype conversions Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant