我有一个沿着下面的数据框:
Type Set 1 A Z 2 B Z 3 B X 4 C Y
我想在数据帧中添加另一列(或生成一系列)与数据帧相同的长度(=相等的记录/行数),如果Set ='Z'则设置颜色为绿色,如果Set =否则设置为'red' .
最好的方法是什么?
python numpy dataframe pandas
dataframe ×1
numpy ×1
pandas ×1
python ×1