-2
city_df["Geography"].str.endswith("Quebec")

This is my code which gives me list of True and False. I want get all the names of cities that are set to True.

haneulkim
  • 4,406
  • 9
  • 38
  • 80
  • 1
    Possible duplicate of [Select rows from a DataFrame based on values in a column in pandas](https://stackoverflow.com/questions/17071871/select-rows-from-a-dataframe-based-on-values-in-a-column-in-pandas) – Erfan Mar 11 '19 at 19:57

1 Answers1

1

you are almost there.

mask = city_df["Geography"].str.endswith("Quebec")
quebec_city = city_df[mask]

provide a more complete example may be helpful.

Dyno Fu
  • 8,753
  • 4
  • 39
  • 64