【发布时间】:2018-02-12 04:01:33
【问题描述】:
我有以下数据框:
Joined User ID
0 2017-08-19 user 182737081
1 2017-05-07 user 227151009
2 2017-11-29 user 227306568
3 2016-05-22 user 13661634
4 2017-01-23 user 220545735
我试图弄清楚如何绘制用户随时间的增长。我认为最好的方法是绘制一个累积和。我整理了一个简单的代码:
tmp = members[['Joined']].copy()
tmp['count'] = 1
tmp.set_index('Joined', inplace=True)
这会产生以下cumsum:
count
Joined
2017-08-19 1
2017-05-07 2
2017-11-29 3
2016-05-22 4
2017-01-23 5
现在,当我尝试使用 tmp.plot() 进行绘制时,我得到了一些超级奇怪的东西,呃:
- 我真的不知道这个图实际显示的是什么(这看起来像是某种累积 delta 趋势线?)
- 如何绘制随时间的累积用户增长 ????
我正在使用的 pandas 版本:pandas (0.20.3)
如果您好奇系列的长度是否与最高计数相同:
tmp.cumsum().max() == len(tmp)
count True
dtype: bool
【问题讨论】:
标签: python pandas matplotlib plot