itertuples does not work with categorical column in dataframe · Issue #7839 · pandas-dev/pandas (original) (raw)

Code Snippet

df = pd.DataFrame({"id":[1,2,3,4,5,6], "raw_grade":['a', 'b', 'b', 'a', 'a', 'e']}) df['grade'] = pd.Categorical(df['raw_grade']) for t in df.itertuples(index=False): print(t)

Error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-45-182b29164b1a> in <module>()
      1 df = pd.DataFrame({"id":[1,2,3,4,5,6], "raw_grade":['a', 'b', 'b', 'a', 'a', 'e']})
      2 df['grade'] = pd.Categorical(df['raw_grade'])
----> 3 for t in df.itertuples(index=False):
      4     print(t)

/home/has2k1/scm/pandas/pandas/core/frame.pyc in itertuples(self, index)
    549         # use integer indexing because of possible duplicate column names
    550         arrays.extend(self.iloc[:, k] for k in range(len(self.columns)))
--> 551         return zip(*arrays)
    552 
    553     if compat.PY3:  # pragma: no cover

TypeError: izip argument #3 must support iteration

This is on master at commit 24b309f.

Edit:
Version string - pandas: 0.14.1-78-g24b309f