Remove all comma from starting and ending
For Example
id name
1 ,,par, ind, gop, abc
2 ,raj,
3 marl, govin
4 rajjs, sun,,,
Ans
id name
1 par, ind, gop, abc
2 raj,
3 marl, govin
4 rajjs, sun
>Solution :
You can perform it faster and more efficient way using list comprehensions, avoiding the need for apply or lambdas:
df['name'] = [x.strip() for x in df['name']]