Why does it seem like we called the column twice?

Calculating With Pandas — Column With Partial Data | Dataquest

My Code:

mpg_non_zero=cars.loc[(cars['MPG']>0)]

Actual code:

mpg_non_zero = cars.loc[cars['MPG'] > 0, 'MPG']

Why was there another MPG after the mask stating it is already >0

Hi! We are not calling the column twice. If you try to recall indexing with loc it looks like df.loc[row_index, column_index]. With boolean indexing, we are trying to get all the rows where the values for MPG are bigger than zero. When we add ‘MPG’ for the column index, it means we only want to index the MPG column, meanwhile if you leave it blank, you’ll get all the columns of the data frame.