Pyspark using lpad not accepting length function

497 views Asked by At

I am trying to add a prefix to a string column 'data' value with:

`df.select('data_id',lpad(df['data'],length(df.data) +3 ,'p1/'))`

But I got this error:

TypeError: 'Column' object is not callable

I tried casting with int(length(df.data)), but the message was

TypeError: int() argument must be a string or a number, not 'Column'

I also tried .cast("integer") and I got a similar error.

Additionally, I need to add the prefix just under a condition where 'data_id' is under an interval, like [1 .. 100]. Can you help me?

0

There are 0 answers