We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ec92f15 commit d6179b0Copy full SHA for d6179b0
pandas/core/groupby/generic.py
@@ -769,17 +769,13 @@ def value_counts(
769
nbin = len(levels[-1])
770
ncat = len(codes[0])
771
fout = np.zeros((ncat * nbin), dtype=float if normalize else np.int64)
772
- """
+ id = 0
773
change_ids = np.r_[ # need to update now that we removed full repeats
774
ids[1:] != ids[:-1], True
775
]
776
777
- id = 0
778
- ct_len = len(cts)
779
for i, ct in enumerate(cts): # fill in nonzero values of fout
780
fout[id * nbin + val_lab[i]] = cts[i]
781
- if i < ct_len - 1: # avoid index error
782
- id += ids[i] != ids[i + 1]
+ id += change_ids[i]
783
ncodes = [np.repeat(code, nbin) for code in codes]
784
ncodes.append(np.tile(range(nbin), len(codes[0])))
785
0 commit comments