Skip to content

Commit 029c180

Browse files
fix index dtype in value_counts result
1 parent e5ab629 commit 029c180

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pandas/core/algorithms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ def value_counts_internal(
931931
# For backwards compatibility, we let Index do its normal type
932932
# inference, _except_ for if if infers from object to bool.
933933
idx = Index(keys)
934-
if idx.dtype == bool and keys.dtype == object:
934+
if idx.dtype in [bool, "string"] and keys.dtype == object:
935935
idx = idx.astype(object)
936936
elif (
937937
idx.dtype != keys.dtype # noqa: PLR1714 # # pylint: disable=R1714

0 commit comments

Comments
 (0)