Original manually manipulated function
df2 = df1.withColumn("test1", col("data.test1"))\
.withColumn("test2", col("data.test2"))\
.withColumn("test3", col("data.test3"))\
.withColumn("test4", col("data.test4"))\
.drop("data")
The state of hope?
for col_name in ['test1', 'test2', 'test3', 'test4']:
df1.withColumn(col_name, col(data.col_name)).drop("data")
Like this... Can I add the .withColumn
function by returning the list of column names I want to manipulate to a repeat statement?
I think I just need to interpolate well.
for col_name in ['test1', 'test2', 'test3', 'test4']:
df1.withColumn(col_name, col("data." + col_name)).drop("data")
546 Understanding How to Configure Google API Key
549 PHP ssh2_scp_send fails to send files as intended
709 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
547 Who developed the "avformat-59.dll" that comes with FFmpeg?
548 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.