Skip to content

plot with float_contrast=False causes pandas groupby error #57

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

Closed
dcnadler opened this issue Aug 26, 2019 · 3 comments
Closed

plot with float_contrast=False causes pandas groupby error #57

dcnadler opened this issue Aug 26, 2019 · 3 comments
Labels

Comments

@dcnadler
Copy link

dcnadler commented Aug 26, 2019

Using jupyter notebook in jupyter/scipy-notebook docker container
DockerFile

FROM jupyter/scipy-notebook:2ce7c06a61a1
RUN pip install dabest

Using example from github:

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()

output:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-eb33a02ff120> in <module>
      1 # Produce a Cumming estimation plot.
----> 2 iris_dabest.mean_diff.plot()

/opt/conda/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, swarmplot_kwargs, violinplot_kwargs, slopegraph_kwargs, reflines_kwargs, group_summary_kwargs, legend_kwargs)
   1233         del all_kwargs["self"]
   1234 
-> 1235         out = EffectSizeDataFramePlotter(self, **all_kwargs)
   1236 
   1237         return out

/opt/conda/lib/python3.7/site-packages/dabest/plotter.py in EffectSizeDataFramePlotter(EffectSizeDataFrame, **plot_kwargs)
    375                          gap_width_percent=1.5,
    376                          type=group_summaries, ax=rawdata_axes,
--> 377                          **group_summary_kwargs)
    378 
    379 

/opt/conda/lib/python3.7/site-packages/dabest/plot_tools.py in gapped_lines(data, x, y, type, offset, ax, line_color, gap_width_percent, **kwargs)
    160 
    161     medians   = data.groupby(x)[y].median().reindex(index=group_order)
--> 162     quantiles = data.groupby(x)[y].quantile([0.25, 0.75])\
    163                                   .unstack()\
    164                                   .reindex(index=group_order)

/opt/conda/lib/python3.7/site-packages/pandas/core/groupby/groupby.py in quantile(self, q, interpolation)
   1906             post_processing=post_processor,
   1907             q=q,
-> 1908             interpolation=interpolation,
   1909         )
   1910 

/opt/conda/lib/python3.7/site-packages/pandas/core/groupby/groupby.py in _get_cythonized_result(self, how, grouper, aggregate, cython_dtype, needs_values, needs_mask, needs_ngroups, result_is_index, pre_processing, post_processing, **kwargs)
   2246                 func = partial(func, ngroups)
   2247 
-> 2248             func(**kwargs)  # Call func to modify indexer values in place
   2249 
   2250             if result_is_index:

pandas/_libs/groupby.pyx in pandas._libs.groupby.group_quantile()

TypeError: must be real number, not list

I have noticed this error tends to happen when using float_contrast=False (either specified with two samples, or when using more than two samples).

@josesho josesho added the bug label Aug 27, 2019
@josesho
Copy link
Member

josesho commented Aug 27, 2019

Hi @dcnadler,

This seems suspiciously familiar to #52. Are you using pandas==0.25.0?

@dcnadler
Copy link
Author

@josesho, yes pandas 0.25.0

@josesho
Copy link
Member

josesho commented Aug 27, 2019

Can you try either downgrading to 0.24 or upgrading to 0.25.1?

@josesho josesho closed this as completed Aug 30, 2019
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

2 participants