我无法通过动态调用exec函数来对现有数据框进行更改。
>>>>df.columns
["col1","col2"]
>>>>change = "df.withColumnRenamed('col2','column2')"
>>>>exec("df =" + change)
电流输出
>>>>df.columns
["col1","col2"]
预期产量
>>>>df.columns
["col1","column2"]
执行运行没有任何问题。但是该列并未重命名。我尝试了几次更改,但无济于事