0

I do have a df containing three columns (Date, Manufacturer, Country, Sales Unit) which seems something like below:

Date              Country          Manufacturer       Sales Unit
22-03-2019         China               BMW                200
27-04-2013         Korea             Mahindra             150
02-02-2015         India               Tata               200
13-02-2014         China               Ford               450          
21-04-2019         India             Mahindra             432
27-05-2019         China              Toyota              212 

I want to filter out the data of the China only, so the dataset will look something like that after filtering:

Date              Country          Manufacturer       Sales Unit
22-03-2019         China               BMW                200
13-02-2014         China               Ford               450
27-05-2019         China              Toyota              212 

How to do it using Python's library Panda?

Damien Rice
  • 111
  • 5

1 Answers1

1

Two common approaches to retrieving a subset of a dataframe are the loc and query methods.

Loc example:

df.loc[df["Country"] == "China", :]

Query example:

df.query("Country == 'China'")

You are encouraged to look into the pandas documentation to get a better grasp of these & related methods.