0

I'm trying to use boolean indexing to set the rows with a Title not in ["Mr", "Miss", "Mrs", "Master"] to Rare. Here's my attempt:

combined_df[(~combined_df.Title.isin(["Mr", "Miss", "Mrs", "Master"]))].Title = "Rare"

When I do pd.value_counts(combined_df.Title), I get:

Mr              757
Miss            260
Mrs             197
Master           61
Dr                8
Rev               8
Col               4
Major             2
Mlle              2
Ms                2
Jonkheer          1
the Countess      1
Capt              1
Dona              1
Don               1
Lady              1
Mme               1
Sir               1
Name: Title, dtype: int64

So the attempted changes don't take hold.

Any idea why / how to fix this?

anon_swe
  • 8,791
  • 24
  • 85
  • 145

0 Answers0