Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame({'p': [2, 3] * 4,
                   'q': [True, False] * 4,
                   'r': [2.0, 3.0] * 4})
df
Out[2]:
p q r
0 2 True 2.0
1 3 False 3.0
2 2 True 2.0
3 3 False 3.0
4 2 True 2.0
5 3 False 3.0
6 2 True 2.0
7 3 False 3.0
In [3]:
df.select_dtypes(include='bool')
Out[3]:
q
0 True
1 False
2 True
3 False
4 True
5 False
6 True
7 False
In [4]:
df.select_dtypes(include=['float64'])
Out[4]:
r
0 2.0
1 3.0
2 2.0
3 3.0
4 2.0
5 3.0
6 2.0
7 3.0
In [5]:
df.select_dtypes(exclude=['int'])
Out[5]:
p q r
0 2 True 2.0
1 3 False 3.0
2 2 True 2.0
3 3 False 3.0
4 2 True 2.0
5 3 False 3.0
6 2 True 2.0
7 3 False 3.0