-1

I can't perform any math operations on these values that I had exported. I'm using xlwt library to do this. Any way to convert these values in the format so that I can be able to perform math operations on it.

enter image description here

Ahmed
  • 796
  • 1
  • 5
  • 16
Marcus
  • 15
  • 1
  • 5

3 Answers3

3
float('3629,473.237'.replace(',', ''))
Wasif
  • 14,755
  • 3
  • 14
  • 34
MaxTechniche
  • 141
  • 5
1

You can replace the commas, they make no sense except readablity

n = float("3629,473.237".replace(",",""))

To re-add commas as string, you can use format strings:

print("{:,}".format(n))

There are f-strings in python 3.6+

print(f"{n:,}")
Wasif
  • 14,755
  • 3
  • 14
  • 34
0

No; you'll have to remove the comma manually.

float("123,000.12".replace(',',''))

If you have consistent data, you might as well remove all the commas and convert the result.

Wasif
  • 14,755
  • 3
  • 14
  • 34