Skip to content

Suggestion: Warning for DataFrame colname-methodname clash #5904

Closed
@michaelaye

Description

Would it be costly to issue a warning when one adds a column to a DataFrame that has the same name as a built-in DataFrame method?
As you know, in that case I can not do Dataframe.name to access the column but instead I get a method pointer.
But if I'm unaware (or it's late and I forgot.. ;) ) that a method with that name exists, I could be confused for quite a while before I find out what's going on.

Example I just had:

s = Series(somedata)
Investigating the difference with
s.diff()
Looks interesting, so for easier management I want to put things in a dataframe now.
df = DataFrame(s)
df['diff'] = s.diff()

And then I tried to filter the df for some values in diff and got this:

df[df.diff > 10]
KeyError: u'no item named True'

That somehow didn't make me at all think about a name clash. In this case I eventually guessed what was wrong, but if I wouldn't know that a fancy method with a fancy name exists and I picked it as well, I guess I never would find out, what's going on.

So, if it isn't too much costs in terms of performance a name check against core methods would be really nice, I think.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions