How to Subset Rows in Pandas Dataframes
There are at least 4 methods to subset row in Pandas dataframes. Method 1: loc[[Comma]] df.loc[[row_number1, row_number_2]] Method 2: loc[Colon] df.loc[row_number1: row_number_2] Method 3: iloc[[Comma]] df.iloc[[row_number1, row_number_2]] Method 4: iloc[Colon] df.iloc[[row_number1: row_number_2]] Example 1 for Method 1 The following uses loc[[Comma]] (i.e., loc[[0,2]])to subset rows in a Pandas dataframe. The following shows the original dataframe … Read more