Home > Enterprise >  How do you display all values when using pivot tables in pandas?
How do you display all values when using pivot tables in pandas?

Time:06-24

df_agg = pd.pivot_table(df, values= 'total_revenue', index= 'order_year',aggfunc= 'sum')

When I run the above code, this is what I get. I would love to get the entire figures for the total revenue column.

order_year total_revenue
2010 4.95994e 08
2011 5.23411e 08

CodePudding user response:

you can add pandas set_option to change the way you view the numbers.

Code

df_agg = pd.pivot_table(df, values= 'total_revenue', index= 'order_year',aggfunc= 'sum')
#Used 2 as I think you have financial/currency data
pd.set_option('display.float_format', lambda x: '%.2f' % x) 
df_agg

Output

enter image description here

  • Related