@@ -1841,6 +1841,14 @@ def f(x):
1841
1841
tm.assert_frame_equal(df.groupby(c).transform(sum), df[['a']])
1842
1842
tm.assert_frame_equal(df.groupby(c).transform(lambda xs: np.sum(xs)), df[['a']])
1843
1843
1844
+
# GH 9603
1845
+
df = pd.DataFrame({'a': [1, 0, 0, 0]})
1846
+
c = pd.cut(df.a, [0, 1, 2, 3, 4])
1847
+
result = df.groupby(c).apply(len)
1848
+
expected = pd.Series([1, 0, 0, 0], index=c.values.categories)
1849
+
expected.index.name = 'a'
1850
+
tm.assert_series_equal(result, expected)
1851
+
1844
1852
def test_pivot_table(self):
1845
1853
1846
1854
raw_cat1 = Categorical(["a","a","b","b"], categories=["a","b","z"], ordered=True)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4