Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot plot the figures #113

Open
yinawei opened this issue May 24, 2021 · 3 comments
Open

cannot plot the figures #113

yinawei opened this issue May 24, 2021 · 3 comments
Labels

Comments

@yinawei
Copy link

yinawei commented May 24, 2021

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
Copy link
Member

josesho commented May 25, 2021

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
Copy link
Author

yinawei commented May 25, 2021

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)

@josesho josesho added the bug label May 25, 2021
@Jacobluke-
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants