ts.plot() pandas: No plot!

Chris Angelico rosuav at gmail.com
Sun Jan 31 20:15:26 EST 2016


On Mon, Feb 1, 2016 at 11:46 AM, Paulo da Silva
<p_s_d_a_s_i_l_v_a_ns at netcabo.pt> wrote:
> I am learning pandas and following the tutorial I tried the following:
> ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000',
> periods=1000))
> ts = ts.cumsum()
> ts.plot()
>
> No plot is produced!
> Only the following output:
> <matplotlib.axes.AxesSubplot object at 0x7f33019b6630>
>
> Any clue on what is happening?
>
> I'm using kubuntu and python3.
>

Hmm. Normally I would expect matplotlib to pop up a graph there. Are
you running this from a terminal, or from some sort of GUI? It might
make a difference to how it brings up the graph. Interestingly, I'm
not able to run your example on my system:

>>> pd.__version__
'0.17.1'
>>> pd.date_range('1/1/2000', periods=1000)
ValueError: Error parsing datetime string "1/1/2000" at position 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/pandas/tseries/index.py",
line 1923, in date_range
    closed=closed, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pandas/util/decorators.py",
line 89, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pandas/tseries/index.py",
line 237, in __new__
    ambiguous=ambiguous)
  File "/usr/local/lib/python3.6/site-packages/pandas/tseries/index.py",
line 379, in _generate
    start = Timestamp(start)
  File "pandas/tslib.pyx", line 299, in pandas.tslib.Timestamp.__new__
(pandas/tslib.c:8973)
  File "pandas/tslib.pyx", line 1163, in
pandas.tslib.convert_to_tsobject (pandas/tslib.c:22522)
  File "pandas/tslib.pyx", line 1271, in
pandas.tslib.convert_str_to_tsobject (pandas/tslib.c:24121)
  File "pandas/src/datetime.pxd", line 141, in datetime._string_to_dts
(pandas/tslib.c:80505)
SystemError: <class 'str'> returned a result with an error set

So it's possible you've run into something that's changed between
versions. Your original example works on my 2.7, although it doesn't
pop up a graph. So now I'm a bit lost. :)

ChrisA



More information about the Python-list mailing list