日付、セグメント、メトリックの 3 つの列を持つデータフレーム データがあります。私は次のことをしています:
data = pandas.read_csv("Filename.csv")
ave = data.groupby('Segment').mean() #works
ave = data.groupby('Segment').median() #gives error
ave['median'] = data.groupby('Segment').median()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/lib/pymodules/python2.7/pandas/core/frame.py", line 1453, in __setitem__
self._set_item(key, value)
File "/usr/lib/pymodules/python2.7/pandas/core/frame.py", line 1488, in _set_item
NDFrame._set_item(self, key, value)
File "/usr/lib/pymodules/python2.7/pandas/core/generic.py", line 301, in _set_item
self._data.set(key, value)
File "/usr/lib/pymodules/python2.7/pandas/core/internals.py", line 616, in set
assert(value.shape[1:] == self.shape[1:])
AssertionError