Skip to content

Updated qcut for Float64DType Issue #40730 #40969

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

Merged
merged 9 commits into from
Apr 26, 2021
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ Conversion
- Bug in :class:`Index` construction silently ignoring a passed ``dtype`` when the data cannot be cast to that dtype (:issue:`21311`)
- Bug in :meth:`StringArray.astype` falling back to numpy and raising when converting to ``dtype='categorical'`` (:issue:`40450`)
- Bug in :class:`DataFrame` construction with a dictionary containing an arraylike with ``ExtensionDtype`` and ``copy=True`` failing to make a copy (:issue:`38939`)
-
- Bug in :meth:`qcut` raising error when taking ``Float64DType`` as input (:issue:`40730`)

Strings
^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/reshape/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
is_datetime_or_timedelta_dtype,
is_extension_array_dtype,
is_integer,
is_integer_dtype,
is_list_like,
is_numeric_dtype,
is_scalar,
is_timedelta64_dtype,
)
Expand Down Expand Up @@ -488,7 +488,7 @@ def _coerce_to_type(x):
# Will properly support in the future.
# https://github.com/pandas-dev/pandas/pull/31290
# https://github.com/pandas-dev/pandas/issues/31389
elif is_extension_array_dtype(x.dtype) and is_integer_dtype(x.dtype):
elif is_extension_array_dtype(x.dtype) and is_numeric_dtype(x.dtype):
x = x.to_numpy(dtype=np.float64, na_value=np.nan)

if dtype is not None:
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/reshape/test_qcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ def test_qcut_bool_coercion_to_int(bins, box, compare):


@pytest.mark.parametrize("q", [2, 5, 10])
def test_qcut_nullable_integer(q, any_nullable_int_dtype):
arr = pd.array(np.arange(100), dtype=any_nullable_int_dtype)
def test_qcut_nullable_integer(q, any_nullable_numeric_dtype):
arr = pd.array(np.arange(100), dtype=any_nullable_numeric_dtype)
arr[::2] = pd.NA

result = qcut(arr, q)
Expand Down