Skip to content

Commit 275d951

Browse files
committed
fixup on merge of changes in algorithms.py
1 parent 2e5d012 commit 275d951

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,
@@ -525,19 +525,6 @@ def value_counts(values, sort=True, ascending=False, normalize=False,
525525
except TypeError:
526526
raise TypeError("bins argument only works with numeric data.")
527527

528-
if is_categorical_dtype(values) or is_sparse(values):
529-
530-
# handle Categorical and sparse,
531-
result = Series(values).values.value_counts(dropna=dropna)
532-
result.name = name
533-
counts = result.values
534-
535-
else:
536-
keys, counts = _value_counts_arraylike(values, dropna)
537-
538-
if not isinstance(keys, Index):
539-
keys = Index(keys)
540-
result = Series(counts, index=keys, name=name)
541528
# count, remove nulls (from the index), and but the bins
542529
result = ii.value_counts(dropna=dropna)
543530
result = result[result.index.notnull()]
@@ -551,6 +538,22 @@ def value_counts(values, sort=True, ascending=False, normalize=False,
551538
# normalizing is by len of all (regardless of dropna)
552539
counts = np.array([len(ii)])
553540

541+
else:
542+
543+
if is_categorical_dtype(values) or is_sparse(values):
544+
545+
# handle Categorical and sparse,
546+
result = Series(values).values.value_counts(dropna=dropna)
547+
result.name = name
548+
counts = result.values
549+
550+
else:
551+
keys, counts = _value_counts_arraylike(values, dropna)
552+
553+
if not isinstance(keys, Index):
554+
keys = Index(keys)
555+
result = Series(counts, index=keys, name=name)
556+
554557
if sort:
555558
result = result.sort_values(ascending=ascending)
556559

0 commit comments

Comments
 (0)