ACCLAB / DABEST-python

Data Analysis with Bootstrapped ESTimation
https://acclab.github.io/DABEST-python/
Apache License 2.0
339 stars 47 forks source link

cannot plot the figures #113

Closed yinawei closed 3 months ago

yinawei commented 3 years ago

The error occurred while calling "two_groups_unpaired.cohens_d.plot"

ImportError: cannot import name 'recode_for_categories' from 'pandas.core.arrays.categorical' (/Users/yinawei/opt/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/core/arrays/categorical.py)

josesho commented 3 years ago

Hi @jelyness ,

Can you provide a copy-pastable example of the data and code you are using?

Also, can you run

dabest.__version__

and

pandas.__version__

and report what versions are printed?

Thanks!

yinawei commented 3 years ago

It works before. I think it could be the version issue. $ dabest.version '0.3.1' $ pandas.version '1.2.4'

I have the same issue while running your sample code: import pandas as pd import dabest iris = pd.read_csv("https://github.com/mwaskom/seaborn-data/raw/master/iris.csv") iris_dabest = dabest.load(data=iris, x="species", y="petal_width", idx=("setosa", "versicolor", "virginica")) iris_dabest.mean_diff.plot();


ImportError Traceback (most recent call last)

in 10 11 # Produce a Cumming estimation plot. ---> 12 iris_dabest.mean_diff.plot(); ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/dabest/_classes.py in plot(self, color_col, raw_marker_size, es_marker_size, swarm_label, contrast_label, swarm_ylim, contrast_ylim, custom_palette, swarm_desat, halfviolin_desat, halfviolin_alpha, float_contrast, show_pairs, group_summaries, group_summaries_offset, fig_size, dpi, ax, swarmplot_kwargs, violinplot_kwargs, slopegraph_kwargs, reflines_kwargs, group_summary_kwargs, legend_kwargs) 1691 del all_kwargs["self"] 1692 -> 1693 out = EffectSizeDataFramePlotter(self, **all_kwargs) 1694 1695 return out ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/dabest/plotter.py in EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs) 391 order=all_plot_groups, hue=color_col, 392 palette=plot_palette_raw, zorder=1, --> 393 **swarmplot_kwargs) 394 395 # Plot the gapped line summaries, if this is not a Cumming plot. ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/seaborn/_decorators.py in inner_f(*args, **kwargs) 44 ) 45 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)}) ---> 46 return f(**kwargs) 47 return inner_f 48 ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/seaborn/categorical.py in swarmplot(x, y, hue, data, order, hue_order, dodge, orient, color, palette, size, edgecolor, linewidth, ax, **kwargs) 2990 2991 plotter = _SwarmPlotter(x, y, hue, data, order, hue_order, -> 2992 dodge, orient, color, palette) 2993 if ax is None: 2994 ax = plt.gca() ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/seaborn/categorical.py in __init__(self, x, y, hue, data, order, hue_order, dodge, orient, color, palette) 1170 dodge, orient, color, palette): 1171 """Initialize the plotter.""" -> 1172 self.establish_variables(x, y, hue, data, orient, order, hue_order) 1173 self.establish_colors(color, palette, 1) 1174 ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/seaborn/categorical.py in establish_variables(self, x, y, hue, data, orient, order, hue_order, units) 205 # Group the numeric data 206 plot_data, value_label = self._group_longform(vals, groups, --> 207 group_names) 208 209 # Now handle the hue levels for nested ordering ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/seaborn/categorical.py in _group_longform(self, vals, grouper, order) 251 252 # Group the val data --> 253 grouped_vals = vals.groupby(grouper) 254 out_data = [] 255 for g in order: ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/core/generic.py in groupby(self, by, axis, level, as_index, sort, group_keys, squeeze, observed, **kwargs) 7892 if not isinstance(index, DatetimeIndex): 7893 raise TypeError("Index must be DatetimeIndex") -> 7894 7895 indexer = index.indexer_at_time(time, asof=asof) 7896 return self._take_with_is_copy(indexer, axis=axis) ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/core/groupby/groupby.py in groupby(obj, by, **kwds) 2520 Cumulative max for each group. 2521 -> 2522 Returns 2523 ------- 2524 Series or DataFrame ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/core/groupby/groupby.py in __init__(self, obj, keys, axis, level, grouper, exclusions, selection, as_index, sort, group_keys, squeeze, observed, **kwargs) 389 Function to use for aggregating the data. If a function, must either 390 work when passed a {klass} or when passed to {klass}.apply. --> 391 392 Accepted combinations are: 393 ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/core/groupby/grouper.py in _get_grouper(obj, key, axis, level, sort, observed, mutated, validate) 650 multiple groupers 651 --> 652 Groupers are ultimately index mappings. They can originate as: 653 index mappings, keys to columns, functions, or Groupers 654 ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/core/groupby/grouper.py in __init__(self, index, grouper, obj, name, level, sort, observed, in_axis) 311 # pandas\core\groupby\grouper.py:310: error: Value of type variable 312 # "FrameOrSeries" of "get_grouper" cannot be "Optional[Any]" --> 313 # [type-var] 314 self.grouper, _, self.obj = get_grouper( # type: ignore[type-var] 315 self.obj, ~/opt/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/core/groupby/categorical.py in 4 5 from pandas.core.algorithms import unique1d ----> 6 from pandas.core.arrays.categorical import ( 7 Categorical, 8 CategoricalDtype, ImportError: cannot import name 'recode_for_categories' from 'pandas.core.arrays.categorical' (/Users/yinawei/opt/miniconda3/envs/py3/lib/python3.7/site-packages/pandas/core/arrays/categorical.py)
Jacobluke- commented 1 year ago

Hi @yinawei , can you try to create another environment and install DABEST, the latest version of pandas to check if the problem remains?

Jacobluke- commented 3 months ago

Close issue due to lack of response