Skip to main content
edited body
Source Link
pbahr
  • 1.4k
  • 12
  • 14

In case you would like to apply a simple transformation on all column names, this code does the trick: (I am replacing all blanksspaces with underscore)

new_column_name_list= list(map(lambda x: x.replace(" ", "_"), df.columns)) df = df.toDF(*new_column_name_list) 

Thanks to @user8117731 for toDf trick.

In case you would like to apply a simple transformation on all column names, this code does the trick: (I am replacing all blanks with underscore)

new_column_name_list= list(map(lambda x: x.replace(" ", "_"), df.columns)) df = df.toDF(*new_column_name_list) 

Thanks to @user8117731 for toDf trick.

In case you would like to apply a simple transformation on all column names, this code does the trick: (I am replacing all spaces with underscore)

new_column_name_list= list(map(lambda x: x.replace(" ", "_"), df.columns)) df = df.toDF(*new_column_name_list) 

Thanks to @user8117731 for toDf trick.

deleted 3 characters in body
Source Link
pbahr
  • 1.4k
  • 12
  • 14

In case you would like to apply a simple transformation on all column names, this code does the trick: (I am replacing all blanks with underscore)

new_column_name_list= list(map(lambda x: x.replace(" ", "_"), df.columns)) df = df.toDF(*new_column_name_list) 

Thanks to @petter-friberg@user8117731 for toDf trick.

In case you would like to apply a simple transformation on all column names, this code does the trick: (I am replacing all blanks with underscore)

new_column_name_list= list(map(lambda x: x.replace(" ", "_"), df.columns)) df = df.toDF(*new_column_name_list) 

Thanks to @petter-friberg for toDf trick.

In case you would like to apply a simple transformation on all column names, this code does the trick: (I am replacing all blanks with underscore)

new_column_name_list= list(map(lambda x: x.replace(" ", "_"), df.columns)) df = df.toDF(*new_column_name_list) 

Thanks to @user8117731 for toDf trick.

Source Link
pbahr
  • 1.4k
  • 12
  • 14

In case you would like to apply a simple transformation on all column names, this code does the trick: (I am replacing all blanks with underscore)

new_column_name_list= list(map(lambda x: x.replace(" ", "_"), df.columns)) df = df.toDF(*new_column_name_list) 

Thanks to @petter-friberg for toDf trick.