Slicing DataFrames
You can access subsets of your dataframe (views) in a few different ways, but we will focus on two here.
Name-based indexing
You provide a row_index and a column_index - they can be slices or lists or whatever to the .loc[row_names, col_names] indexer
example: [your_dataframe_name].loc[my_row_names, my col_names].Index-based indexing
You provide the row and column numbers to the .iloc[row_numbers, col_numbers]
example: [your_dataframe_name].iloc[my_row_numbers, my col_numbers]ms.loc[:,'Protein Name'] #get all row (:), 'Protein Name' column


Side topic: get familiar with [List Comprehension]

['Protein Name', 'Protein Preferred Name', 'Protein Gene']
['Protein Name', 'Protein Preferred Name', 'Protein Gene']







Last updated
Was this helpful?
