简体   繁体   中英

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

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

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

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM