There's more...

We can do a very similar operation to make .loc work with a mixture of integers and positions. The following shows how to select the 10th through 15th (inclusive) rows, along with columns UGDS_WHITE through UGDS_UNKN:

>>> row_start = df_college.index[10]
>>> row_end = df_college.index[15]
>>> college.loc[row_start:row_end, 'UGDS_WHITE':'UGDS_UNKN']

Doing this same operation with .ix (which is deprecated, so don't do this) would look like this:

>>> college.ix[10:16, 'UGDS_WHITE':'UGDS_UNKN']

It is possible to achieve the same results by chaining .loc and .iloc together, but chaining indexers is typically a bad idea:

>>> college.iloc[10:16].loc[:, 'UGDS_WHITE':'UGDS_UNKN']
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.97.187