Skip to content

Commit 7685d62

Browse files
committed
fixup on merge of changes in algorithms.py
1 parent ab4fde4 commit 7685d62

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

pandas/core/algorithms.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
is_bool_dtype, needs_i8_conversion,
2020
is_categorical, is_datetimetz,
2121
is_datetime64_any_dtype, is_datetime64tz_dtype,
22-
is_timedelta64_dtype,
22+
is_timedelta64_dtype, is_interval_dtype,
2323
is_scalar, is_list_like,
2424
_ensure_platform_int, _ensure_object,
2525
_ensure_float64, _ensure_uint64,
@@ -529,19 +529,6 @@ def value_counts(values, sort=True, ascending=False, normalize=False,
529529
except TypeError:
530530
raise TypeError("bins argument only works with numeric data.")
531531

532-
if is_categorical_dtype(values) or is_sparse(values):
533-
534-
# handle Categorical and sparse,
535-
result = Series(values).values.value_counts(dropna=dropna)
536-
result.name = name
537-
counts = result.values
538-
539-
else:
540-
keys, counts = _value_counts_arraylike(values, dropna)
541-
542-
if not isinstance(keys, Index):
543-
keys = Index(keys)
544-
result = Series(counts, index=keys, name=name)
545532
# count, remove nulls (from the index), and but the bins
546533
result = ii.value_counts(dropna=dropna)
547534
result = result[result.index.notnull()]
@@ -555,6 +542,22 @@ def value_counts(values, sort=True, ascending=False, normalize=False,
555542
# normalizing is by len of all (regardless of dropna)
556543
counts = np.array([len(ii)])
557544

545+
else:
546+
547+
if is_categorical_dtype(values) or is_sparse(values):
548+
549+
# handle Categorical and sparse,
550+
result = Series(values).values.value_counts(dropna=dropna)
551+
result.name = name
552+
counts = result.values
553+
554+
else:
555+
keys, counts = _value_counts_arraylike(values, dropna)
556+
557+
if not isinstance(keys, Index):
558+
keys = Index(keys)
559+
result = Series(counts, index=keys, name=name)
560+
558561
if sort:
559562
result = result.sort_values(ascending=ascending)
560563

0 commit comments

Comments
 (0)