如何解决如何在“团队”列中混洗标签“爱国者”和“马驹”? 蟒蛇
假设这是数据,我如何在“团队”列中将标签“爱国者”和“马驹”改组,然后将其附加到新列?
Team Blakeman Prioleau Combined Pressure Drop
0 Patriots 11.50 11.80 11.650 0.850
1 Patriots 10.85 11.20 11.025 1.475
2 Patriots 11.15 11.50 11.325 1.175
3 Patriots 10.70 11.00 10.850 1.650
4 Patriots 11.10 11.45 11.275 1.225
5 Patriots 11.60 11.95 11.775 0.725
6 Patriots 11.85 12.30 12.075 0.425
7 Patriots 11.10 11.55 11.325 1.175
8 Patriots 10.95 11.35 11.150 1.350
9 Patriots 10.50 10.90 10.700 1.800
10 Patriots 10.90 11.35 11.125 1.375
11 Colts 12.70 12.35 12.525 0.475
12 Colts 12.75 12.30 12.525 0.475
13 Colts 12.50 12.95 12.725 0.275
14 Colts 12.55 12.15 12.350 0.650
解决方法
您是否正在寻找类似的东西?
import pandas as pd
import numpy as np
df = pd.DataFrame({'Team': ['Patriots','Patriots','Colts'],'Blakeman':[11.50,10.85,12.70]})
df['new_col'] = np.random.permutation(df['Team'].values)
df
Team Blakeman new_col
0 Patriots 11.50 Colts
1 Patriots 10.85 Patriots
2 Colts 12.70 Patriots
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。