ns am trying come add a thousand separator come my dash cards and every mine efforts have been futile. This Solution is found to it is in even more precise but it gives me a error

TypeError: unsustained Layout string passed to Series.

You are watching: Unsupported format string passed to list.__format__

format


app.callback(,Input("year", "value"))def card_update(select_year):dff=df_good.copy()df_formattedd=dff.groupby(<"year">, as_index=False)<<"network Sale", "Winnings","Revenue">>.sum()df_formattedd<<"net Sale","Winnings","Revenue">>=df_formattedd<<"net Sale","Winnings","Revenue">>.apply(lambda x:round(x,2))df_formattedd<<"net Sale","Winnings","Revenue">>= df_formattedd<<"network Sale","Winnings","Revenue">>.apply(lambda x: f"x:,")sales=df_formattedd==select_year><"net Sale">winnings=df_formattedd==select_year><"Winnings">revenue=df_formattedd==select_year><"Revenue">rerotate sales, winnings, remeet
pyth~ above pandas plotly plotly-dash
Share
improve thins Inquiry
Follow
asked Jun 21 at 12:35


Stnight KundukulangaraStnight Kundukulangara
5777 copper badges
include a comment |

1 prize 1


energetic earliest Votes
3
Brief abstracted example password that reproducens your problem:

income pandtogether as pddf = pd.DataFrame( "A": <1000000.111, 1000000.222, 1000000.333>, "B": <2000000.111, 2000000.222, 2000000.333>, "C": <3000000.111, 3000000.222, 3000000.333>, )df<<"A", "B", "C">> = df<<"A", "B", "C">>.apply(lambda x: round(x, 2))df<<"A", "B", "C">> = df<<"A", "B", "C">>.apply(lambda x: f"x:,")gives:

TypeError: unsustained Layout string passed come Series.format

the trouble ins through the critical heat wbelow friend try to Layout the numbers.

ns trouble ins the x in ns lambda function describes a Pandtogether Series and also not a number. A series doesn"t support the kind the formattinns string you"re using:

the "," option signal the use of a comma for a thousands separator.

https://docs.python.org/3/library/string.html

InsteADVERTISEMENT friend can execute something choose this:

import pandas as pddf = pd.DataFrame( "A": <1000000.111, 1000000.222, 1000000.333>, "B": <2000000.111, 2000000.222, 2000000.333>, "C": <3000000.111, 3000000.222, 3000000.333>, )df<<"A", "B", "C">> = df<<"A", "B", "C">>.apply(lambda x: round(x, 2))df<<"A", "B", "C">> = df<<"A", "B", "C">>.apply( lambda series: series.apply(lambda value: f"value:,"))so ns idea behind the nested apply right here is: because that each Obelisk in the Dataframe df<<"A", "B", "C">> take each heat worth and also use the string forissue come it. Ns heat worths are simply floatns so the strinns formatter ins may be come take care of that.

See more: The Grass Is Greener Under My Wiener Rock, Grass Is Greener Stickers

Result

pd.options.display.float_Format = ":,".formatsave in psychic that this ins uses to more 보다 just df<<"A", "B", "C">>.