Python Pandas groupby and qcut doesn't work in 0.14.1 -


i bin observations group , put bin assignment dataframe:

in [60]: df = pd.dataframe({'x': np.random.rand(20), 'grp': ['a'] * 10 + ['b'] * 10})  in [61]: df['y'] = df.groupby('grp')['x'].transform(pd.qcut, 3) traceback (most recent call last):    file "<ipython-input-61-fe2f09d0bbe2>", line 1, in <module>     df.groupby('grp')['x'].transform(pd.qcut, 3)    file "c:\python\python-2.7.6.amd64\lib\site-packages\pandas\core\groupby.py", line 2286, in transform     result[indexer] = res  valueerror: not convert string float: (0.352, 0.784] 

the code above used work in 0.13 believe, not seem work in 0.14.1. idea?

here's workaround, wrapping categorical created qcut in series.

df['y'] = df.groupby('grp')['x'].apply(lambda x: pd.series(pd.qcut(x,3), index=x.index)) 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -