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=['tiger', 'lion'],
                  columns=['one', 'two', 'three'])

Pandas: DataFrame - filter.

In [3]:
# select columns by name
df.filter(items=['one', 'three'])
Out[3]:
one three
tiger 2 4
lion 5 7

Pandas: DataFrame - select columns by name.

In [4]:
# select columns by regular expression
df.filter(regex='e$', axis=1)
Out[4]:
one three
tiger 2 4
lion 5 7

Pandas: DataFrame - select columns by regular expression.

In [5]:
# select rows containing 'ion'
df.filter(like='ion', axis=0)
Out[5]:
one two three
lion 5 6 7

Pandas: DataFrame - select rows containing 'ion'.