Skip to content

Instantly share code, notes, and snippets.

@takluyver
Created October 12, 2011 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takluyver/1281034 to your computer and use it in GitHub Desktop.
Save takluyver/1281034 to your computer and use it in GitHub Desktop.
Plotting pandas columns
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
/home/thomas/Experiments/Emergence depth/<ipython-input-5-1c9d8c0f3fd8> in <module>()
----> 1 plot(soy_w['Depth'])
/home/thomas/code/virtualenvs/mpl/lib/python2.7/site-packages/matplotlib/pyplot.pyc in plot(*args, **kwargs)
2284 ax.hold(hold)
2285 try:
-> 2286 ret = ax.plot(*args, **kwargs)
2287 draw_if_interactive()
2288 finally:
/home/thomas/code/virtualenvs/mpl/lib/python2.7/site-packages/matplotlib/axes.pyc in plot(self, *args, **kwargs)
3781 lines = []
3782
-> 3783 for line in self._get_lines(*args, **kwargs):
3784 self.add_line(line)
3785 lines.append(line)
/home/thomas/code/virtualenvs/mpl/lib/python2.7/site-packages/matplotlib/axes.pyc in _grab_next_args(self, *args, **kwargs)
315 return
316 if len(remaining) <= 3:
--> 317 for seg in self._plot_args(remaining, kwargs):
318 yield seg
319 return
/home/thomas/code/virtualenvs/mpl/lib/python2.7/site-packages/matplotlib/axes.pyc in _plot_args(self, tup, kwargs)
292 x = np.arange(y.shape[0], dtype=float)
293
--> 294 x, y = self._xy_from_xy(x, y)
295
296 if self.command == 'plot':
/home/thomas/code/virtualenvs/mpl/lib/python2.7/site-packages/matplotlib/axes.pyc in _xy_from_xy(self, x, y)
239 x = x[:,np.newaxis]
240 if y.ndim == 1:
--> 241 y = y[:,np.newaxis]
242 return x, y
243
/usr/local/lib/python2.7/dist-packages/pandas/core/series.pyc in __getitem__(self, key)
265 # e.g. as requested by np.median
266
--> 267 return _index_with(key)
268
269 def _multilevel_index(self, key):
/usr/local/lib/python2.7/dist-packages/pandas/core/series.pyc in _index_with(indexer)
249 def _index_with(indexer):
250 return Series(self.values[indexer],
--> 251 index=self.index[indexer])
252
253 # boolean
/usr/local/lib/python2.7/dist-packages/pandas/core/series.pyc in __new__(cls, data, index, dtype, name, copy)
126
127 elif subarr.ndim > 1:
--> 128 raise Exception('Data must be 1-dimensional')
129
130 if index is None:
Exception: Data must be 1-dimensional
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment