我有一个数据集,它有一个赢家和输家列。如何使数据集中部分的数据相互之间发生变化?我试过了。
from random import randint
switcher = data.copy()
for i in range(len(data)):
if randint(0, 100) % 2 == 1:
data['name.win'][i], data['name.lose'][i], \
data['country.win'][i], data['country.lose'][i], \
data['rating.win'][i], data['rating.lose'][i], \
data['civ.win.name'][i], data['civ.lose.name'][i] \
= \
switcher['name.lose'][i], switcher['name.win'][i], \
switcher['country.lose'][i], switcher['country.win'][i], \
switcher['rating.lose'][i], switcher['rating.win'][i], \
switcher['civ.lose.name'][i], switcher['civ.win.name'][i]
else:
pass
尝试这样的事情: