You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> df = pd.DataFrame([{'x': 60}, {'x': 70}, {'x': 1514}, {'x': 1514}, {'x': 1514}, {'x': 1019}, {'x': 60}, {'x': 77}, {'x': 60}, {'x': 60}, {'x': 60}], dtype=pd.UInt32Dtype())
>>> df['x'].quantile(0.75)
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/pandas/core/arrays/integer.py", line 126, in safe_cast
return values.astype(dtype, casting="safe", copy=copy)
TypeError: Cannot cast array data from dtype('O') to dtype('uint32') according to the rule 'safe'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/pandas/core/series.py", line 2447, in quantile
result = df.quantile(q=q, interpolation=interpolation, numeric_only=False)
File "/usr/local/lib/python3.9/site-packages/pandas/core/frame.py", line 10290, in quantile
res = self.quantile(
File "/usr/local/lib/python3.9/site-packages/pandas/core/frame.py", line 10309, in quantile
res = data._mgr.quantile(qs=q, axis=1, interpolation=interpolation)
File "/usr/local/lib/python3.9/site-packages/pandas/core/internals/managers.py", line 1338, in quantile
blocks = [
File "/usr/local/lib/python3.9/site-packages/pandas/core/internals/managers.py", line 1339, in <listcomp>
blk.quantile(axis=axis, qs=qs, interpolation=interpolation)
File "/usr/local/lib/python3.9/site-packages/pandas/core/internals/blocks.py", line 1324, in quantile
result = quantile_compat(self.values, np.asarray(qs._values), interpolation)
File "/usr/local/lib/python3.9/site-packages/pandas/core/array_algos/quantile.py", line 46, in quantile_compat
out = _quantile_ea_fallback(values, qs, interpolation)
File "/usr/local/lib/python3.9/site-packages/pandas/core/array_algos/quantile.py", line 184, in _quantile_ea_fallback
out = type(values)._from_sequence(res, dtype=values.dtype)
File "/usr/local/lib/python3.9/site-packages/pandas/core/arrays/integer.py", line 323, in _from_sequence
values, mask = coerce_to_array(scalars, dtype=dtype, copy=copy)
File "/usr/local/lib/python3.9/site-packages/pandas/core/arrays/integer.py", line 231, in coerce_to_array
values = safe_cast(values, dtype, copy=False)
File "/usr/local/lib/python3.9/site-packages/pandas/core/arrays/integer.py", line 133, in safe_cast
raise TypeError(
TypeError: cannot safely cast non-equivalent object to uint32
root@572eb14c4d4f:/tmp# pip3 show numpy
Name: numpy
Version: 1.21.0
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: None
License: BSD
Location: /usr/local/lib/python3.9/site-packages
Requires:
Required-by: scipy, scikit-learn, pandas
root@572eb14c4d4f:/tmp# pip3 show pandas
Name: pandas
Version: 1.3.0
Summary: Powerful data structures for data analysis, time series, and statistics
Home-page: https://pandas.pydata.org
Author: The Pandas Development Team
Author-email: [email protected]
License: BSD-3-Clause
Location: /usr/local/lib/python3.9/site-packages
Requires: pytz, numpy, python-dateutil
root@572eb14c4d4f:/tmp# python3 --version
Python 3.9.6
The text was updated successfully, but these errors were encountered:
numpy uint32 is fine, but pd.Uint32Dtype() is not, on the same series:
Now Pandas:
The text was updated successfully, but these errors were encountered: