ENH: Add empty property to Index. by ssanderson · Pull Request #15270 · pandas-dev/pandas (original) (raw)
I don't think the current docstring on NDFrame would make sense if moved here, since it makes references to NDFrame, and it has examples geared toward DataFrame, both of which would be confusing if they showed up on a property of Index.
Coming back to this with fresh eyes, I'm now inclined to just put empty on the base Index class and give it an Index-specific docstring. The root issue here is that there are two places from which Series could be getting it's implementation of empty: NDFrame, which provides shared implementations for Series/DataFrame/Panel, and IndexOpsMixin, which provides shared implementations for Index and Series. In the case of empty (and, in general, any property that belongs on both containers and indexes) I think putting the implementation on IndexOpsMixin ends up being more confusing than helpful, because it's no longer clear which implementation will end up getting used for Series. Does that seem reasonable?
Separately, I could replace the current implementation of NDFrame.empty with this if you think it's preferable, though I'm not sure it's a worthwhile improvement by itself.