Padding in a Pyspark Dataframe

Viewed 23720

I have a Pyspark dataframe(Original Dataframe) having below data(all columns have string datatype):

  id           Value
   1             103
   2             1504
   3              1  

I need to create a new modified dataframe with padding in value column, so that length of this column should be 4 characters. If length is less than 4 characters, then add 0's in data as shown below:

  id             Value
   1             0103
   2             1504
   3             0001  

Can someone help me out? How can i achieve it using Pyspark dataframe? Any help will be appreciated.

2 Answers
Related