-1

I have a dataset like below. I want to perform a filtering process according to a specific value in one of the columns.

For example, this is the original dataset:

Name ... Age ...... Phone_Type

Joun .... 25 ......... iPhone

Alex ..... 20 ....... Samsung

Sam .....60 ....... Nokia

David ...30........ iPhone

......................................

I want to filter all records to show only the users who are using "iPhone" by Python.

The Result should be:

Joun .... 25 ......... iPhone

David ...30........ iPhone

Jamie
  • 47
  • 8
  • 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) – Terry Mar 08 '19 at 22:36

1 Answers1

0

Assuming you have a dataframe like this:

df = pd.DataFrame({'Name': ['Joun','Alex','Sam','David'], 'Age': [25,20,60,30],'Phone_Type':['iPhone','Samsung','Nokia','iPhone']})

You should try:

df.loc[df['Phone_Type'] == 'iPhone']

vmouffron
  • 418
  • 1
  • 4
  • 11