我正在尝试在pandas中交换相同DataFrame中的行.
我试过跑步
a = pd.DataFrame(data = [[1,2],[3,4]], index=range(2), columns = ['A', 'B'])
b, c = a.iloc[0], a.iloc[1]
a.iloc[0], a.iloc[1] = c, b
Run Code Online (Sandbox Code Playgroud)
但我最后得到的两行显示第二行的值(3,4).
即使变量b和c现在都分配给3和4,即使我没有再次分配它们.难道我做错了什么?