Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2023 12:34 AM
That is totally possible.
f.e. here is a function that trims all string columns in a dataframe. You can change it to your needs:
def trim_all_string_columns(df: dataframe) -> dataframe:
for c in df.schema.fields:
if isinstance(c.dataType, StringType):
df = df.withColumn(c.name, F.trim(F.col(c.name)))
return df