Indexing

As we saw in the previous section, we can easily combine column selection and row slicing; however, it got a little messy and rather long. If we decide to use the chained selection methods discussed in the Selection and Slicing sections to update values in our data, we will find pandas complaining that we aren't doing it correctly (even if it works). This is to warn us that setting data with a sequential selection may not give us the result we anticipate. More information can be found at http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy.

Let's trigger this warning to understand it better. We will try to update the title of a few earthquakes to be in lowercase:

>>> df[110:113]['title'] = df[110:113]['title'].str.lower() ...

Get Hands-On Data Analysis with Pandas now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.