A number of nanops functions rely on the private internal function nanops._maybe_null_out
. These include nansum
, nanmin
, nanmax
, and nanprod
. All of these, in principle, should work with arrays with a complex dtype. However, due to a bug in _maybe_null_out
, they convert the array to a float under certain situations, resulting in erroneous results. The easiest way to trigger this is to have a complex array where all the imaginary values are nan, and make axis
argument something other than None
.
>>> from pandas.core import nanops >>> import bottleneck >>> import numpy as np >>> nanops._USE_BOTTLENECK = False >>> >>> val = np.tile(1, (11, 7)) + np.tile(np.nan*1j, (11, 7)) >>> >>> bottleneck.nansum(val, axis=0) array([ nan+0.j, nan+0.j, nan+0.j, nan+0.j, nan+0.j, nan+0.j, nan+0.j]) >>> nanops.nansum(val, axis=0) array([ nan, nan, nan, nan, nan, nan, nan]) >>> bottleneck.nansum(val, axis=0).dtype dtype('complex128') >>> nanops.nansum(val, axis=0).dtype dtype('float64')
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4