Skip to content

Commit c64385c

Browse files
committed
Remove workaround for categoricals in stat_summary
The workaround was due to a bug in pandas, pandas-dev/pandas#10409 that has been fixed. When that was fixed upstream, the local fix led to another bug, pandas-dev/pandas#10696!!
1 parent 034422f commit c64385c

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

doc/changelog.rst

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ v0.2.1
1212
- Fixed bug where computed aesthetics could not be used in larger
1313
statements. (:issue:`7`)
1414

15+
- Fixed bug in :class:`~plotnine.stat_summary` where the you got
16+
an exception for some types of the `x` aesthetic values.
17+
1518

1619
v0.2.0
1720
------

plotnine/stats/stat_summary.py

-12
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,6 @@ def compute_panel(cls, data, scales, **params):
204204
params['fun_ymin'], params['fun_ymax'],
205205
params['fun_args'])
206206

207-
# NOTE: This is a temporary fix due to bug
208-
# https://github.com/pydata/pandas/issues/10409
209-
# Remove when that bug is fixed
210-
import pandas.api.types as pdtypes
211-
212-
def preserve_categories(ref, other):
213-
for col in ref.columns & other.columns:
214-
if pdtypes.is_categorical_dtype(ref[col]):
215-
other[col] = other[col].astype(
216-
'category', categories=ref[col].cat.categories)
217-
218207
# break a dataframe into pieces, summarise each piece,
219208
# and join the pieces back together, retaining original
220209
# columns unaffected by the summary.
@@ -227,7 +216,6 @@ def preserve_categories(ref, other):
227216
if 'y' in unique:
228217
unique = unique.drop('y', axis=1)
229218
merged = summary.merge(unique, on=['group', 'x'])
230-
preserve_categories(unique, merged) # see above note
231219
summaries.append(merged)
232220

233221
new_data = pd.concat(summaries, axis=0, ignore_index=True)

0 commit comments

Comments
 (0)