Select Rows From A DataFrame Based On Multiple Values In A Column In Pandas
This is not a repetitive question, yet similar to Select rows from a DataFrame based on values in a column in pandas In that answer up in the previous link it is only based on o
Solution 1:
you may use .isin():
In [28]: df2[df2['id'].isin(['SP.POP.TOTL','NY.GNP.PCAP.CD'])]
Out[28]:
id name \
7478 NY.GNP.PCAP.CD GNI per capita, Atlas method (current US$)
9568 SP.POP.TOTL Population, total
source \
7478 World Development Indicators
9568 World Development Indicators
sourceNote \
7478 GNI per capita (formerly GNP per capita) is th...
9568 Total population is based on the de facto defi...
sourceOrganization \
7478 b'World Bank national accounts data, and OECD ...
9568 b'(1) United Nations Population Division. Worl...
topics
7478 Economy & Growth ; Climate Change
9568 Health ; Climate Change
Post a Comment for "Select Rows From A DataFrame Based On Multiple Values In A Column In Pandas"