I have a DataFrame consisting of 500 columns out of which, for each row I need to get the average of set of columns starting with "country_"
.
expr=[F.sum(train_data_df[x])/colCount for x in train_data_df.columns if 'country_' in x]
avg_train_data_df = train_data_df.withColumn('avg', *expr)
I get the following error response:
TypeError: withColumn() takes 3 positional arguments but 212 were given