1In [96]: df
2Out[96]:
3 A B C D
4a 1 4 9 1
5b 4 5 0 2
6c 5 5 1 0
7d 1 3 9 6
8
9In [99]: df[(df.A == 1) & (df.D == 6)]
10Out[99]:
11 A B C D
12d 1 3 9 6
1# filter rows for year 2002 using the boolean expression
2>gapminder_2002 = gapminder[gapminder.year.eq(2002)]
3>print(gapminder_2002.shape)
4(142, 6)
1>continents = ['Asia','Africa', 'Americas', 'Europe']
2>gapminder_Ocean = gapminder[~gapminder.continent.isin(continents)]
3>gapminder_Ocean.shape
4(24,6)
5
1#To select rows whose column value is in list
2years = [1952, 2007]
3gapminder.year.isin(years)