wesm/pandas — Issue #378: Exception Upon Pivoting an Empty DataFrame
Author: craustin
Created: 2011-11-17 18:52:42+00:00
State: open

from pandas import DataFrame
df = DataFrame({},columns=['time','item','value'])
df.pivot('time','item','value')

pandas\core\frame.pyc in pivot(self, index, columns, values)
1953 """
1954 from pandas.core.reshape import pivot
-> 1955 return pivot(self, index=index, columns=columns, values=values)
1956
1957 def stack(self, level=-1, dropna=True):

pandas\core\reshape.pyc in pivot(self, index, columns, values)
220 stacked = stacked.sortlevel(level=0)
221
--> 222 unstacked = stacked.unstack()
223 if values is not None:
224 unstacked.columns = unstacked.columns.droplevel(0)

pandas\core\frame.pyc in unstack(self, level)
2017 return result
2018 else:
-> 2019 return unstack(self, level)
2020
2021 def delevel(self):

pandas\core\reshape.pyc in unstack(obj, level)
289 unstacker = _Unstacker(obj.values, obj.index, level=level,
290 value_columns=columns)
--> 291 return unstacker.get_result()
292
293 def stack(frame, level=-1, dropna=True):

pandas\core\reshape.pyc in get_result(self)
120
121 # filter out missing levels

--> 122 values = values[:, mask]
123 columns = columns[mask]
124

IndexError: invalid index