-1

I am attempting to remove Scientific Notation from my data frame to no avail

AgeBreakdown = Variables_of_Interest2.groupby('age').agg(Total_Suicides = ('suicides_no', 'sum'))

I then attempted to float display pd.options.display.float_format = '{:, .2f}'.format

but it does not alter the figures in my dataframe

Same output

Ynjxsjmh
  • 28,441
  • 6
  • 34
  • 52
DavidJohnZ
  • 11
  • 2
  • 1
    Scientific notation is not part of the frame (or array), but rather something that is used for the display. At least for numpy arrays, it is only used when the range of values is large - very small number along with larger ones. I'm not sure what pandas is doing. – hpaulj Mar 11 '23 at 23:49
  • 1
    This has nothing to do with your dataframe. The data frame contains float's, how they are *displayed* is not relevant and a seperate issue. The image you posted is clearly some IDE feature, and it isn't clear how you are supposed to control the output there. In any case, *why does this matter to you*? – juanpa.arrivillaga Mar 11 '23 at 23:56
  • @juanpa.arrivillaga I want to create a bar chart with the subsequent data – DavidJohnZ Mar 12 '23 at 00:03
  • 1
    @DavidJohnZ ok, so this doesn't affect that. What exactly is it that you are trying to accomplish? Is the notation showing up on the bar chart you create, using something like `matplotlib`? – juanpa.arrivillaga Mar 12 '23 at 00:31
  • I wonder what the dataframe `dtypes` are. The fact that it's showing some values as ints, e.g. `45000`, and others a `1. 7543e6`, ie, `1,743,000` (my commas), 1.7 million, is a bit supicious. A numpy array display would use scientific notation for all values. Is the column int, float, or object (string)? – hpaulj Mar 12 '23 at 01:37
  • https://stackoverflow.com/q/21137150/7758804 – Trenton McKinney Mar 12 '23 at 03:38
  • @juanpa.arrivillaga Yes when I create the bar chart the notion is what turns up on the X axis – DavidJohnZ Mar 13 '23 at 08:29
  • @DavidJohnZ then the issue is in how you create the bar chart. This is an example of an [X-Y problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) – juanpa.arrivillaga Mar 13 '23 at 10:20

1 Answers1

0

Have you tried :

pd.set_option('display.float_format', lambda x: f'{x:,.2f}')

?

harriet
  • 540
  • 3
  • 9