Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
df = pd.DataFrame(np.array(([2, 3, 4], [5, 6, 7])),
                  index=['bat', 'cat'],
                  columns=['one', 'two', 'three'])
In [3]:
# select columns by name
df.filter(items=['one', 'three'])
Out[3]:
one three
bat 2 4
cat 5 7
In [4]:
# select columns by regular expression
df.filter(regex='e$', axis=1)
Out[4]:
one three
bat 2 4
cat 5 7
In [5]:
# select rows containing 'ca'
df.filter(like='ca', axis=0)
Out[5]:
one two three
cat 5 6 7