Skip to content

Commit

Permalink
TST/API: related GH5614, groupby.cumsum returned frames
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed May 1, 2014
1 parent 614e273 commit 371a7bf
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pandas/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2030,13 +2030,19 @@ def test_non_cython_api(self):
assert_frame_equal(result,expected)

# cumsum (GH5614)
df = DataFrame([[1, 2, np.nan], [1, np.nan, 9], [3, 4, 9]], columns=['A', 'B', 'C'])
expected = DataFrame([[2, np.nan], [np.nan, 9], [4, 9]], columns=['B', 'C'])
result = df.groupby('A').cumsum()
df = DataFrame([[1, 2, np.nan], [1, np.nan, 9], [1, 1, 2 ], [3, 4, 9]], columns=['A', 'B', 'C'])
import pdb; pdb.set_trace()
expected = DataFrame([[2, np.nan], [np.nan,9], [3, 11], [4, 9]],
columns=['B', 'C'],
index=MultiIndex.from_tuples([(1,0),(1,1),(1,2),(3,0)],names=['A',None]))
g = df.groupby('A')
result = g.cumsum()
assert_frame_equal(result,expected)

expected = DataFrame([[1, 2, np.nan], [2, np.nan, 9], [3, 4, 9]], columns=['A', 'B', 'C']).astype('float64')
result = df.groupby('A', as_index=False).cumsum()
expected = DataFrame([[1, 2, np.nan], [2, np.nan, 9], [3, 3, 11], [3, 4, 9]],
columns=['A', 'B', 'C'])
g = df.groupby('A', as_index=False)
result = g.cumsum()
assert_frame_equal(result,expected)

def test_grouping_ndarray(self):
Expand Down

0 comments on commit 371a7bf

Please sign in to comment.