Skip to content

ERR: better error reporting with .transform and an invalid output from a UDF #10165

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
jreback opened this issue May 18, 2015 · 1 comment
Closed
Labels
Docs Error Reporting Incorrect or improved errors from pandas
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented May 18, 2015

xref #9697

I think we can detect the returned values and if they are not scalars, give a nicer error message. Further a doc-note would be helpful.

In [4]: cols = pd.MultiIndex.from_tuples([('syn', 'A'), ('mis', 'A'), ('non', 'A'),     ('syn', 'C'), ('mis', 'C'), ('non', 'C'),
                              ('syn', 'T'), ('mis', 'T'), ('non', 'T'), ('syn', 'G'), ('mis', 'G'), ('non', 'G')])

In [5]: df = pd.DataFrame(np.random.randint(1, 10, (4,12)), columns=cols, index=['A', 'C', 'G', 'T'])

In [6]: df.groupby(axis=1, level=1).transform(lambda z: z.div(z.sum(axis=1), axis=0))
ValueError: Length mismatch: Expected axis has 4 elements, new values have 12 elements
@tomowind
Copy link

Pull request 12474 submitted

@jreback jreback modified the milestones: 0.18.0, Next Major Release Feb 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants