As discussed in #6063:
I noticed that that numpy-style access breaks sometimes under 0.13. While I haven't been able to pin-point the issue, calls like pylab.hist(-df.ix[row, col_name])
fail with some x[0]
index error and I have to use pylab.hist(-df.ix[row, col_name]).values
.
Here is a csv file for which this happens: https://gist.github.com/8651509
plt.hist(pd.read_csv('debug.csv'))
produces:
-------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-203-b20a1ff5d1db> in <module>() ----> 1 hist(pd.load('debug.pickle')) /home/ipython/envs/ipynb/local/lib/python2.7/site-packages/matplotlib/pyplot.pyc in hist(x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, hold, **kwargs) 2825 histtype=histtype, align=align, orientation=orientation, 2826 rwidth=rwidth, log=log, color=color, label=label, -> 2827 stacked=stacked, **kwargs) 2828 draw_if_interactive() 2829 finally: /home/ipython/envs/ipynb/local/lib/python2.7/site-packages/matplotlib/axes.pyc in hist(self, x, bins, range, normed, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs) 8247 # Massage 'x' for processing. 8248 # NOTE: Be sure any changes here is also done below to 'weights' -> 8249 if isinstance(x, np.ndarray) or not iterable(x[0]): 8250 # TODO: support masked arrays; 8251 x = np.asarray(x) /home/ipython/envs/ipynb/local/lib/python2.7/site-packages/pandas/core/series.pyc in __getitem__(self, key) 482 def __getitem__(self, key): 483 try: --> 484 result = self.index.get_value(self, key) 485 if isinstance(result, np.ndarray): 486 return self._constructor(result,index=[key]*len(result)).__finalize__(self) /home/ipython/envs/ipynb/local/lib/python2.7/site-packages/pandas/core/index.pyc in get_value(self, series, key) 1030 1031 try: -> 1032 return self._engine.get_value(s, k) 1033 except KeyError as e1: 1034 if len(self) > 0 and self.inferred_type == 'integer': /home/ipython/envs/ipynb/local/lib/python2.7/site-packages/pandas/index.so in pandas.index.IndexEngine.get_value (pandas/index.c:2890)() /home/ipython/envs/ipynb/local/lib/python2.7/site-packages/pandas/index.so in pandas.index.IndexEngine.get_value (pandas/index.c:2702)() /home/ipython/envs/ipynb/local/lib/python2.7/site-packages/pandas/index.so in pandas.index.IndexEngine.get_loc (pandas/index.c:3440)() /home/ipython/envs/ipynb/local/lib/python2.7/site-packages/pandas/hashtable.so in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6595)() /home/ipython/envs/ipynb/local/lib/python2.7/site-packages/pandas/hashtable.so in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6536)() KeyError: 0
While passing .values
works.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4