pandas 从熊猫数据框中绘制累积图表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37293014/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Draw a cumulative chart from a pandas dataframe?
提问by Richard
I have a dataframe as follows:
我有一个数据框如下:
df = pd.DataFrame({'cost_saving': [10, 10, 20, 40, 60, 60],
'id': ['a', 'b', 'c', 'd', 'e', 'f']})
How can I draw a cumulative chart of the savings?
如何绘制储蓄累积图表?
I'm thinking of a line chart with number of items on the x-axis, and total savings on the y-axis.
我正在考虑一个折线图,x 轴上有项目数,y 轴上有总储蓄。
The chart should show that the bulk of the savings come from a few items.
该图表应显示大部分节省来自少数项目。
I've tried:
我试过了:
dftest['cost_saving'].plot(drawstyle='steps')
but it doesn't plot the cumulative values.
但它没有绘制累积值。
Thanks for any help!
谢谢你的帮助!