绘图时tseries/convertor中的Pandas RuntimeError [英] pandas RuntimeError in tseries/convertor when plotting

查看:69
本文介绍了绘图时tseries/convertor中的Pandas RuntimeError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我执行以下语句时:

DataFrame(randn(3,1),index=[date(2012,10,1),date(2012,9,1),date(2012,8,1)],columns=['test']).plot() 

我收到以下异常:

文件"/usr/local/lib/python2.7/dist-packages/pandas-0.10.0-py2.7-linux-x86_64.egg/pandas/tseries/converter.py",第317行,在通话 (估计,dmin,dmax,self.MAXTICKS * 2)) RuntimeError:MillisecondLocator估计从2012-08-01 00:00:00 + 00:00到2012-10-01 00:00:00 + 00:00产生5270400个滴答:超过Locator.MAXTICKS * 2(2000)

此错误有任何解决方法吗?

解决方案

一种解决方法是在绘制之前进行排序:

df.sort().plot()

它看起来像个错误,所以我将其发布在 github 上!

注意:如果使用datetime而不是date,这似乎可以更好地绘制刻度:

df1 = DataFrame(randn(3,1), index=[datetime(2012,10,1), datetime(2012,9,1), datetime(2012,8,1)], columns=['test'])

When I execute the following statement:

DataFrame(randn(3,1),index=[date(2012,10,1),date(2012,9,1),date(2012,8,1)],columns=['test']).plot() 

I get the following exception:

File "/usr/local/lib/python2.7/dist-packages/pandas-0.10.0-py2.7-linux-x86_64.egg/pandas/tseries/converter.py", line 317, in call (estimate, dmin, dmax, self.MAXTICKS * 2)) RuntimeError: MillisecondLocator estimated to generate 5270400 ticks from 2012-08-01 00:00:00+00:00 to 2012-10-01 00:00:00+00:00: exceeds Locator.MAXTICKS* 2 (2000)

Any workaround available for this bug ?

解决方案

One workaround is to sort before plotting:

df.sort().plot()

It looks like a bug, so I posted it on github!

Note: this seems to plot ticks better if you use datetime rather than date:

df1 = DataFrame(randn(3,1), index=[datetime(2012,10,1), datetime(2012,9,1), datetime(2012,8,1)], columns=['test'])

这篇关于绘图时tseries/convertor中的Pandas RuntimeError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆