1

I have a Series with Name as the index and a number in scientific notation such as 3.176154e+08. How can I convert this number to 317,615,384.61538464 with a thousands separator? I tried:

format(s, ',')

But it returns TypeError: non-empty format string passed to object.format There are no NaNs in the data.

Thanks for your help!

Bellerofont
  • 1,081
  • 18
  • 17
  • 16
lori_lane
  • 35
  • 2
  • 5
  • @raninjan Thank you for the help! That works perfectly. I saw that other thread but didn't realize I needed to apply the lambda. – lori_lane Jan 31 '17 at 21:18

2 Answers2

7

You can use '{:,}'.format(s) as described in response to another similar question on stackoverflow. Using your example:

s = pd.Series([3.176154e+08,3.176154e+08],name='Name') 
s.apply(lambda x: '{:,}'.format(x))
Community
  • 1
  • 1
raninjan
  • 186
  • 7
0

You can also use

SeriesName.map('{:,}'.format)

Ana
  • 11
  • 6