BUG: revert collision warning by deniederhut · Pull Request #17298 · pandas-dev/pandas (original) (raw)
Thanks a lot!
One related thing is that it would be nice if one actually gets a warning when you try to overwrite a built-in so not assigning a column like df['mean']
which does not override the .mean()
method, but with df.mean = [...]
.
Example with master:
In [1]: df = pd.DataFrame({'test': [1, 2, 3, 4]})
In [2]: df
Out[2]:
test
0 1
1 2
2 3
3 4
In [3]: df.mean = [2, 3, 4, 5]
In [4]: df
Out[4]:
test
0 1
1 2
2 3
3 4
In [5]: df.mean()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-4bf1ee5cd33c> in <module>()
----> 1 df.mean()
TypeError: 'list' object is not callable
(but didn't look in detail, so not sure if this is actually possible / easy to do)