Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Float Formatting
#1
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
Reply
#2
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?
Reply
#3
(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.
Reply
#4
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"?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Formatting float number output barryjo 2 879 May-04-2023, 02:04 PM
Last Post: barryjo
  formatting float like int for whole values Skaperen 8 1,674 Apr-11-2022, 01:56 PM
Last Post: deanhystad
  Comaparing Float Values of Dictionary Against A Float Value & Pick Matching Key firebird 2 3,326 Jul-25-2019, 11:32 PM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020