You could use pd.cut as follows: df['col2'] = pd.cut(df['col1'], bins=[0, 10, 50, float('Inf')], labels=['xxx', 'yyy', 'zzz']). Output:
確定! 回上一頁