Python and Titanic competition how to get the median of specific range of values where class is 3
If I understand the problem correctly, you want to fill all missing values in the Fare column by the median value of the Fare column where Pclass=3. This can be achieved by putting the extra row filter test['Pclass']=3 on median of the fare column, see below.

test['Fare'] = test['Fare'].fillna(test.loc[test['Pclass']=3,'Fare'].median())