Skip to content

Binning failure when calling stat_summary_bin #123

Description

@RishiSadhir

The function compute_group appears to be failing in stat_summary_bin.py on line 140. We get the following index error: IndexError: arrays used as indices must be of integer (or boolean) type

The following Python code can reproduce the error:

import numpy as np
import pandas as pd
from plotnine import *

df = pd.DataFrame({"x": np.random.normal(50, 50, 1000), "y": np.random.normal(50, 50, 1000)})
ggplot(df, aes("x", "y")) + stat_summary_bin(geom="point", fun_y=np.mean, bins=10)

Comparable R code that runs just fine:

library(ggplot2)
df = data.frame(x = seq(from=1, to=100, by=1), y = seq(from=1, to=100, by=1),)
ggplot(df, aes(x, y)) + stat_summary_bin(geom="point", fun.y=mean, bins=10)

Let me know if I can be of any more assistance. I love plotnine and thanks for all your hard work.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions