How to edit the output of a pivot table

Viewed 29

this is my code and the image is the output of the code in jupyter notebook, it is possible to fix the numbers of decimals to see the full table ?

df.pivot_table(values="ratio" , index="type", aggfunc=lambda x: [np.percentile(x, 10), np.percentile(x, 20),
                                                                     np.percentile(x, 30), np.percentile(x, 40),
                                                                     np.percentile(x, 50), np.percentile(x, 60),
                                                                     np.percentile(x, 70), np.percentile(x, 80),
                                                                     np.percentile(x, 90), np.percentile(x, 100)])

output of the code in jupyter notebook

PS: "type" = tipo_de_viaje

1 Answers

You could consider using np.round() to wrap the np.percentile() and specify the number of decimals you want. Also consider having each value as a separate column, rather than return lists except you are certain you want lists as the results.

Pandas gives a summary view of your data. to see the entire thing you may consider looping over the pandas frame and printing the result:

[a for a in df.ratio]

or plain old

for a in df.ratio:
    print(a)

This way you get to see it all

Related