-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Description
I had code that was perhaps broken by the latest release.
It seems like I used to be able to use Series from a pandas DataFrame as arguments to gsw.z_from_p(). I.e. this worked:
df = pd.DataFrame({'pressure': [0, 10, 20],
'latitude': [70, 70, 70]})
df['depth'] = -1 * gsw.z_from_p(df['pressure'],
df['latitude'])
df
| pressure | latitude | depth |
|---|---|---|
| 0 | 70 | 0.000000 |
| 10 | 70 | 9.898516 |
| 20 | 70 | 19.796552 |
but with v3.4.0, the same code gives me this error.
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
<ipython-input-3-54c6a5ed8806> in <module>
1 df['depth'] = -1 * gsw.z_from_p(df['pressure'],
----> 2 df['latitude'])
/opt/conda/envs/py37/lib/python3.7/site-packages/gsw/_fixed_wrapped_ufuncs.py in z_from_p(p, lat, geo_strf_dyn_height, sea_surface_geopotential)
13 _z_from_p = z_from_p
14 def z_from_p(p, lat, geo_strf_dyn_height=0, sea_surface_geopotential=0):
---> 15 return _z_from_p(p, lat, geo_strf_dyn_height, sea_surface_geopotential)
16 z_from_p.__doc__ = _z_from_p.__doc__
17
/opt/conda/envs/py37/lib/python3.7/site-packages/gsw/_utilities.py in wrapper(*args, **kw)
60 kw['p'] = newargs.pop()
61
---> 62 ret = f(*newargs, **kw)
63
64 if isinstance(ret, tuple):
/opt/conda/envs/py37/lib/python3.7/site-packages/gsw/_wrapped_ufuncs.py in z_from_p(p, lat, geo_strf_dyn_height, sea_surface_geopotential)
4424
4425 """
-> 4426 return _gsw_ufuncs.z_from_p(p, lat, geo_strf_dyn_height, sea_surface_geopotential)
/opt/conda/envs/py37/lib/python3.7/site-packages/pandas/core/generic.py in __array_ufunc__(self, ufunc, method, *inputs, **kwargs)
1933 self, ufunc: Callable, method: str, *inputs: Any, **kwargs: Any
1934 ):
-> 1935 return arraylike.array_ufunc(self, ufunc, method, *inputs, **kwargs)
1936
1937 # ideally we would define this to avoid the getattr checks, but
/opt/conda/envs/py37/lib/python3.7/site-packages/pandas/core/arraylike.py in array_ufunc(self, ufunc, method, *inputs, **kwargs)
284 raise NotImplementedError(
285 "Cannot apply ufunc {} to mixed DataFrame and Series "
--> 286 "inputs.".format(ufunc)
287 )
288 axes = self.axes
NotImplementedError: Cannot apply ufunc <ufunc 'z_from_p'> to mixed DataFrame and Series inputs.
This works:
df['depth'] = -1 * gsw.z_from_p(df['pressure'].values,
df['latitude'].values)
What is the appropriate behavior here?
Thanks,
Liz
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels