The practical answer:. You should think of iloc and loc as pandas extensions of the python list and dictionary, respectively, and treat them as search queries, not function or method calls. Thus, observing the python syntax, always use [] , not () .
>>> ser = pd.Series( { 'a':3, 'c':9 } ) >>> ser.loc['a']
This is basically the same for dataframes, just with an extra dimension to indicate, and also where iloc and loc become more useful, but beyond the scope of this question.
Deeper answer: If you are really trying to understand this at a deeper level, you need to understand __getitem__ . Perhaps you can start here for some basics. The answers in the second link given in the comments above by @ayhan are also great for your question.
source share