I wish to add dollar symbol in front of all the values in my column.
Data
JavaScript
x
6
1
ID Price
2
aa 800
3
bb 2
4
cc 300
5
cc 4
6
Desired
JavaScript
1
6
1
ID Price
2
aa $800
3
bb $2
4
cc $300
5
cc $4
6
Doing
JavaScript
1
2
1
df.loc["Price"] ='$'+ df["Price"].map('{:,.0f}'.format)
2
I believe I have to map this, not 100% sure. Any suggestion is appreciated.
Advertisement
Answer
You can also try
JavaScript
1
2
1
df["Price"] = '$' + df["Price"].astype(str)
2