I am trying to replace all the fields which have "." within the field name to "_".
This is what I have:
def apply_renaming_mapping(df):
"""Given a dynamic data frame, if the field contains ., replace with _"""
# construct renaming mapping for ApplyMapping
mappings = list()
# for field in df.schema.fields:
for name, dtpye in df.dtypes:
if '.' in name:
mappings.append((name, dtype, name.replace('.', '_'), dtype))
# apply mapping
reanmed= ApplyMapping(frame=df, mappings=mappings)
return renamed
But I think I am missing some pieces. Keep getting the following error: in relationalize_and_write renamed = apply_renaming_mapping(m_df.toDF()) File apply_renaming_mapping reanmed= ApplyMapping(frame=df, mappings=mappings) TypeError: ApplyMapping() takes no arguments During handling of the above exception, another exception occurred: Traceback (most recent call last):
What am I doing wrong here?