pyspark convert '.' in table columns into '_'
Private research annotation
Sign in to add a private research label or note.
- User
pyspark convert '.' in table columns into '_'
- Assistant
To replace dots
.with underscores_in the column names of a PySpark DataFrame, you can use thewithColumnRenamedmethod for each column. Here's a step-by-step approach to achieve this:- Create a list of the new column names by replacing
.with_. - Use
withColumnRenamedin a loop to rename each column.
Here's some example code to illustrate how you can do this:
python - Create a list of the new column names by replacing