Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

None handling in groupby, Series.unique #778

Closed
wesm opened this issue Feb 13, 2012 · 1 comment
Closed

None handling in groupby, Series.unique #778

wesm opened this issue Feb 13, 2012 · 1 comment
Labels
Milestone

Comments

@wesm
Copy link
Member

wesm commented Feb 13, 2012

from mailing list. this is caused by the change in handling of None in PyObjectHashTable

import datetime
import numpy
import pandas

def simple_test2():
   data = [
           [1, 'string1', 1.0],
           [2, 'string2', 2.0],
           [3, None, 3.0]
          ]

   df = pandas.DataFrame({'key': [x[0] for x in data], 'grouper':
[x[1] for x in data], 'value': [x[2] for x in data]})
   df['weights'] = df['value']/df['value'].sum()
   gb = df.groupby('grouper').aggregate(numpy.sum)

   print
   print df
   print ''
   print gb

if __name__ == '__main__':
   simple_test2()




0.7rc1 yields:

 grouper  key  value  weights
0 string1  1    1      0.1667
1 string2  2    2      0.3333
2 NaN      3    3      0.5000

        key  value  weights
grouper
None     3    3      0.5000
string1  1    1      0.1667
string2  2    2      0.3333

0.7 final yields:
  grouper  key  value   weights
0  string1    1      1  0.166667
1  string2    2      2  0.333333
2     None    3      3  0.500000

        key  value   weights
grouper
string1    1      1  0.166667
string2    2      2  0.333333

missing the last line
@wesm
Copy link
Member Author

wesm commented Feb 18, 2012

Fixed Series.unique issue. groupby will be addressed by separate ticket #443

@wesm wesm closed this as completed Feb 18, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant