how can I pass the df columns as a parameter

g96g
New Contributor III

Im doing the self study and want pass df column name as a parameter.

I have defined the widget

column_name= dbutils.widgets.get('column_name')

which is executing succefuly ( giving me a column name)

then Im reading the df and do some transformation and after that I want to wrtie back to datalake.

try:
    (df2[column_name].write
     .mode('append')
     .parquet(f'/mnt/bro/Default/{table_name}'))
except Exception as e:
    print(e)
    raise Exception(e)

then, idea is that adf pipeline will loop through different files after.

but when i run the above code I get error

'DataFrame' object has no attribute 'column_name'

Im sorry if my explanation is not good enough, I just started learning.