In [1]: import pandas as pd
In [2]: import numpy as np
In [3]: df = pd.DataFrame({'city': ['北京', '上海', '广州']})
In [4]: df['t'] = np.where(df.city == '北京', 'A', np.where(df.city == '上海', 'B', np.where(df.city == '广州', 'C', '?')))
In [5]: df
Out[5]:
city t
0 北京 A
1 上海 B
2 广州 C