How to do it...

  1. Read in the college dataset and assign the institution name (INSTNM) as the index:
>>> college = pd.read_csv('data/college.csv', index_col='INSTNM')
  1. Use the Index method get_loc to find the integer position of the desired columns:
>>> col_start = college.columns.get_loc('UGDS_WHITE')
>>> col_end = college.columns.get_loc('UGDS_UNKN') + 1
>>> col_start, col_end
  1. Use col_start and col_end to select columns by integer location using .iloc:
>>> college.iloc[:5, col_start:col_end]

..................Content has been hidden....................

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