Python Forum

Full Version: Float Formatting
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm trying to format a float and I can't seem to figure it out. I've been able to make the float only have two decimal places. But I need to format it a little more so that it shows as 4+22.92

   N6=NFile[NFile['Node'].str.match(N5,na=False)]['Mile']
   N7=N6.to_string(header=None,index=False).strip()
   N8=float(N7)*5280
   N9 = float("{':.2f}".format(N8))

   N8 shows 422.928
   N9 shows 422.92

   How can I make N9 show as 4+22.92
I don't understand what "4+22.92" is supposed to mean. As it doesn't look like a standard numeric format, could you explain how to get there? Do you just want to chop off the first digit, or all digits from the 100s place or greater?
(Jul-30-2020, 03:26 PM)bowlofred Wrote: [ -> ]I don't understand what "4+22.92" is supposed to mean. As it doesn't look like a standard numeric format, could you explain how to get there? Do you just want to chop off the first digit, or all digits from the 100s place or greater?

It's a custom format in excel '###0+00.00' I don't want to chop off any digits at this point, I already did some formatting so it does decimal places instead of three as shown above. Now I want to add the custom format.
I still don't know what that means. You want a plus sign inserted between the hundreds and the tens digits?

"422.92" -> "4+22.92"?
"1144.0" -> "11+44.0"?