Discretize features

Imports

import pandas as pd
import numpy as np

from sklearn.preprocessing import Binarizer

Create data

d = {'values': [6, 10, 12, 100]}
df = pd.DataFrame(d)
df

values
0 6
1 10
2 12
3 100

Option 1: Binarize into 0/1

binarizer = Binarizer(10)
binarizer.fit_transform(df)
array([[0],
       [0],
       [1],
       [1]])

Option 2: Break feature into bins

np.digitize(df, bins=[10, 15])
array([[0],
       [1],
       [1],
       [2]])