Pandas Series indexing: Why .loc beats [] for retrieval

Pandas Series indexing: Why .loc beats [] for retrieval

To retrieve from a Python Pandas series, you can use [] to retrieve items.

But don’t!

In a series, [] uses the index. In a data frame, [] uses the column names. Confusing!

Besides, .loc does everything [] does, but with more options and flexibility.