Here is an example (I just through it together hastily). You can probably do this a little bit smoother.
import pandas as pd
import numpy as np
from random import shuffle
a = np.repeat(['a', 'b', 'c', 'd', 'e'], 6)
x = np.random.randn(30)
y = np.random.randn(30)
z = np.random.randn(30)
shuffle(a)
a = a.reshape(30, 1)
x = x.reshape(30, 1)
y = y.reshape(30, 1)
z = z.reshape(30, 1)
data = np.concatenate((a, x, y, z), axis=1)
df = pd.DataFrame(data, columns=['item', 'x', 'y', 'z'])
mapping = {'1': ['a', 'b'], '2': ['d'], '3': ['c', 'e']}
for k in mapping:
df.loc[df[df['item'].mask(
~df.item.isin(mapping[k])).notnull()].index.tolist(), 'category'] = k