Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 2nd, 2013  |  syntax: None  |  size: 3.06 KB  |  views: 41  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ---------------------------------------------------------------------------
  2. ValueError                                Traceback (most recent call last)
  3. <ipython-input-28-547c2aa43ab1> in <module>()
  4.      11 new_df = df.copy()    
  5.      12
  6. ---> 13 new_df['size'] = new_df.groupby(['A','B']).transform(np.size)
  7.      14
  8.      15 new_df
  9.  
  10. C:\Python\Python32\lib\site-packages\pandas\core\frame.pyc in __setitem__(self, key, value)
  11.    2036         else:
  12.    2037             # set column
  13. -> 2038             self._set_item(key, value)
  14.    2039
  15.    2040     def _setitem_slice(self, key, value):
  16.  
  17. C:\Python\Python32\lib\site-packages\pandas\core\frame.pyc in _set_item(self, key, value)
  18.    2083         """
  19.    2084         value = self._sanitize_column(key, value)
  20. -> 2085         NDFrame._set_item(self, key, value)
  21.    2086
  22.    2087     def insert(self, loc, column, value):
  23.  
  24. C:\Python\Python32\lib\site-packages\pandas\core\generic.pyc in _set_item(self, key, value)
  25.     580
  26.     581     def _set_item(self, key, value):
  27. --> 582         self._data.set(key, value)
  28.     583         self._clear_item_cache()
  29.     584
  30.  
  31. C:\Python\Python32\lib\site-packages\pandas\core\internals.pyc in set(self, item, value)
  32.    1467         except KeyError:
  33.    1468             # insert at end
  34. -> 1469             self.insert(len(self.items), item, value)
  35.    1470
  36.    1471         self._known_consolidated = False
  37.  
  38. C:\Python\Python32\lib\site-packages\pandas\core\internals.pyc in insert(self, loc, item, value)
  39.    1480
  40.    1481             # new block
  41. -> 1482             self._add_new_block(item, value, loc=loc)
  42.    1483
  43.    1484         except:
  44.  
  45. C:\Python\Python32\lib\site-packages\pandas\core\internals.pyc in _add_new_block(self, item, value, loc)
  46.    1519             loc = self.items.get_loc(item)
  47.    1520         new_block = make_block(value, self.items[loc:loc + 1].copy(),
  48. -> 1521                                self.items, fastpath=True)
  49.    1522         self.blocks.append(new_block)
  50.    1523
  51.  
  52. C:\Python\Python32\lib\site-packages\pandas\core\internals.pyc in make_block(values, items, ref_items, klass, fastpath)
  53.     859             klass = ObjectBlock
  54.     860
  55. --> 861     return klass(values, items, ref_items, ndim=values.ndim, fastpath=fastpath)
  56.     862
  57.     863 # TODO: flexible with index=None and/or items=None
  58.  
  59. C:\Python\Python32\lib\site-packages\pandas\core\internals.pyc in __init__(self, values, items, ref_items, ndim, fastpath)
  60.     693             values = np.array(values, dtype=object)
  61.     694
  62. --> 695         super(ObjectBlock, self).__init__(values, items, ref_items, ndim=ndim, fastpath=fastpath)
  63.     696
  64.     697     @property
  65.  
  66. C:\Python\Python32\lib\site-packages\pandas\core\internals.pyc in __init__(self, values, items, ref_items, ndim, fastpath)
  67.      38         if len(items) != len(values):
  68.      39             raise ValueError('Wrong number of items passed %d, indices imply %d'
  69. ---> 40                              % (len(items), len(values)))
  70.      41
  71.      42         self._ref_locs = None
  72.  
  73. ValueError: Wrong number of items passed 1, indices imply 40
clone this paste RAW Paste Data