我正在try 使用PANDAS.ASSIGN函数.该函数将另一列添加到现有列中.
例如
DataFrame1 = DataFrame1.assign(NewColName=[1,2,3,4])
添加名为"NewColName"
的新列.然而,我的理想列名应该是"Weight [kg]"
,当我try 使用"[ ]"
时,该函数停止工作.我试过在"[ ]"
号公路周围应用%'s
、\'s
和其他类似的方法,但都没有成功.
I know I can just rename the column after giving it any name, such as "PlaceHolderName"
, but is there a way to do this with one line of code? That function does not accept column name inside
" "
, so it feels different compared to something like Index="[[asdsa][[" ....
where I can type whatever I want inside the " "
.
谢谢.