API: New callable indexing makes storing functions in a Series difficult · Issue #13299 · pandas-dev/pandas (original) (raw)
Example of something that previously worked (before 7bbd031):
>>> s = pd.Series([lambda x: x] * 10)
>>> s[s.index > 5] = lambda x: x + 1
But now the second line tries to apply the function in the rhs to the elements of the Series, rather than assigning them (and throws an exception). This is very counter-intuitive when using __setitem__
rather than calling Series.where
directly.