wesm/pandas — Issue #601: DataFrame.groupby bug
Author: xdong
Created: 2012-01-10 02:32:50+00:00
State: open

pandas latest commit: When groupby using multiple columns, I get a TypeError. Furthermore, the TypeError is different on 64bit and 32bit Linux machines.

In [1]: import pandas

In [2]: a = pandas.DataFrame(randn(2, 3))

In [3]: a
Out[3]:
0 1 2
0 -0.7262 0.9849 0.1685
1 -1.0241 -2.3102 -1.1348

In [4]: g = a.groupby([0, 1])

In [5]: g.sum()
Out[5]:

#on Ubuntu64 11.10; numpy 1.6.1
TypeError: object of type 'int' has no len()

#on sles10 32bit; numpy 1.5.1
TypeError: array cannot be safely cast to required type

--------------------------------------

#The following works fine on the 64bit machine, but not on the 32bit:

In [6]: a = pandas.DataFrame(randn(2, 3), columns=['a', 'b', 'c'])

In [7]: a
Out[7]:
a b c
0 0.04682 0.1323 0.5046
1 -0.15613 0.4555 0.4553

In [8]: g = a.groupby(['a', 'b'])

In [9]: g.sum()
Out[9]:

#on sles10 32bit; numpy 1.5.1
TypeError: array cannot be safely cast to required type

-------------------------------------

This bug was not present in the pypi version of pandas. However, that version has a Series index overflow bug on the 32bit machine:

In [10]: a = pandas.Series(randn(2))

In [11]: a
Out[11]:
0 0.08557
1 -0.3659

In [12]: a[100]
Out[12]: 8.318223500663e-312