Skip to content

Commit dae2054

Browse files
committed
Fix order of computed x values in stat_count
The order depended on the result of `pd.unique`, this was not guaranted to align with the computed counts.
1 parent 4a12356 commit dae2054

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

plotnine/stats/stat_count.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ def compute_group(cls, data, scales, **params):
5757
df = pd.DataFrame({'weight': weight, 'x': x})
5858
# weighted frequency count
5959
count = df.pivot_table(
60-
'weight', index=['x'], aggfunc=np.sum)['weight'].values
60+
'weight', index=['x'], aggfunc=np.sum)['weight']
61+
x = count.index
62+
count = count.values
6163
return pd.DataFrame({'count': count.astype(int),
6264
'prop': count / np.abs(count).sum(),
63-
'x': x.unique(),
65+
'x': x,
6466
'width': width})

0 commit comments

Comments
 (0)