Skip to content

ERROR: better error message reporting on inserting incompatible column to frame (GH4107) #4108

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

Merged
merged 1 commit into from
Jul 3, 2013

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Jul 2, 2013

closes #4107

jreback added a commit that referenced this pull request Jul 3, 2013
ERROR: better error message reporting on inserting incompatible column to frame (GH4107)
@jreback jreback merged commit 795004d into pandas-dev:master Jul 3, 2013

try:
df['gr'] = df.groupby(['b', 'c']).count()
except (Exception), detail:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback FYI: this format isn't Python 3 compatible, better to use except Exception as detail and frankly you could collapse all of these lines into:

assertRaisesRegexp(TypeError, "incompatible index of inserted column with frame index", df.__setitem__, 'gr', df.groupby(['b', 'c']).count())

or

def testit(): df['gr'] = df.groupby(['b', 'c']).count()
assertRaisesRegexp(TypeError, "incompatible index of inserted column with frame index", testit)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 2to3 changes in any event

this test (and one above about constructor error msgs) should prob be changed then

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

Successfully merging this pull request may close these issues.

more descriptive error message when assigning dataframe with different index shape to column
2 participants