>>> import pandas as pd
>>> pd.__version__
\'0.16.1\'
>>> s1 = pd.Series([1, 3, 5], index=list(\'abc\'))
>>> s1.iloc(0)
The solution, due to @JohnE, is to use square brackets [0]
instead of (0)
with iloc
.
Some more info after digging through some pandas code.
s1.iloc
makes iloc
look like a method. But it is an attribute and the value of the attribute is _iLocIndexer
. _iLocIndexer
is callable with arguments and it returns a copy of itself ignoring any args or kwargs (see pandas.core.indexing._NDFrameIndexer.call in pandas code). This is why s1.iloc(0)
is a valid call.
When s1.iloc[0]
is called with square brackets, an _iLocIndexer
is instantiated and the call to []
operator results in a call to the iLocIndexer
's `getitem' method.
The same is true for the other indexers - loc
, ix
, at
and iat
. These indexers are installed using setattr
in class method pandas.core.generic.NDFrame._create_indexer.