Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas add thousands separator

# add thousand separator for integers and 2 decimal places for floats
df['count'] = df['count'].apply(lambda x: "{:,}".format(int(x)) if x == int(x) else "{:.2f}%".format(100*x))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #add #thousands #separator
ADD COMMENT
Topic
Name
9+3 =