Permalink
Browse files

BUG: test failure in groupby transform

  • Loading branch information...
1 parent bc4fb0d commit 0113ed44f0b328e4f650ef15796d23c8bed36d31 @wesm wesm committed Oct 14, 2011
Showing with 20 additions and 0 deletions.
  1. +2 −0 RELEASE.rst
  2. +18 −0 pandas/tests/test_groupby.py
View
@@ -47,6 +47,8 @@ pandas 0.5.0
- With new `DataFrame.align` method, speeding up binary operations between
differently-indexed DataFrame objects by 10-25%.
- Significantly sped up conversion of nested dict into DataFrame
+ - Can pass hierarchical index level name to `groupby` instead of the level
+ number if desired (GH #223)
**Bug fixes**
@@ -872,6 +872,24 @@ def test_grouping_ndarray(self):
expected = self.df.groupby('A').sum()
assert_frame_equal(result, expected)
+ def test_apply_example(self):
+ df = DataFrame({'d' : [1.,1.,1.,2.,2.,2.],
+ 'c' : np.tile(['a','b','c'], 2),
+ 'v' : np.arange(1., 7.)})
+
+ def f(group):
+ v = group['v']
+ group['v2'] = (v - v.min()) / (v.max() - v.min())
+ return group
+
+ result = df.groupby('d').apply(f)
+
+ expected = df.copy()
+ expected['v2'] = np.tile([0., 0.5, 1], 2)
+
+ assert_frame_equal(result, expected)
+
+
class TestPanelGroupBy(unittest.TestCase):
def setUp(self):

0 comments on commit 0113ed4

Please sign in to comment.