Skip to content
Advertisement

Using .withColumn on all remaining columns in DF

I want to anonymize or replace almost all columns in a pyspark dataframe except a few ones.

I know its possible to do something like:

JavaScript

However, doing this for all columns is a tedious process. I would rather want to do something along the lines of this:

JavaScript

This does however not seem to work. Is there other work arounds that achieve this?

I guess one solution would be to could create a list of column names and do something along the lines of:

JavaScript

Other suggestions would be of much help.

Advertisement

Answer

You can use select. syntax-wise it won’t be much different but it will only create 1 snapshot.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement