Skip to content

Commit eec338a

Browse files
committed
[groupby][m]: uncomment all failed test and ensure they pass
1 parent 42598fe commit eec338a

1 file changed

Lines changed: 51 additions & 51 deletions

File tree

danfojs-browser/tests/core/groupby.js

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe("groupby", function () {
6565
[ 20, 30, 1 ],
6666
[ 39, 89, 1 ]
6767
];
68-
68+
6969
assert.deepEqual(group_df.col([ "C" ]).count().values, new_data);
7070
});
7171
it("sum column element in group", function () {
@@ -130,38 +130,38 @@ describe("groupby", function () {
130130

131131
assert.deepEqual(group_df.col([ "B", "C" ]).cumsum().values, new_data);
132132
});
133-
// it("cummulative max for groupby", function () {
134-
135-
// let data = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 20, 30, 40 ], [ 39, 89, 78 ] ];
136-
// let cols = [ "A", "B", "C" ];
137-
// let df = new dfd.DataFrame(data, { columns: cols });
138-
// let group_df = df.groupby([ "A" ]);
139-
// let new_data = [ [ 1, 3 ], [ 4, 6 ], [ 20, 40 ], [ 39, 78 ] ];
133+
it("cummulative max for groupby", function () {
140134

135+
let data = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 20, 30, 40 ], [ 39, 89, 78 ] ];
136+
let cols = [ "A", "B", "C" ];
137+
let df = new dfd.DataFrame(data, { columns: cols });
138+
let group_df = df.groupby([ "A" ]);
139+
let new_data = [ [ 1, 3 ], [ 4, 6 ], [ 20, 40 ], [ 39, 78 ] ];
140+
141141

142-
// assert.deepEqual(group_df.col([ "C" ]).cummax().values, new_data);
143-
// });
144-
// it("cummulative min for groupby", function () {
142+
assert.deepEqual(group_df.col([ "C" ]).cummax().values, new_data);
143+
});
144+
it("cummulative min for groupby", function () {
145145

146-
// let data = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 20, 30, 40 ], [ 39, 89, 78 ] ];
147-
// let cols = [ "A", "B", "C" ];
148-
// let df = new dfd.DataFrame(data, { columns: cols });
149-
// let group_df = df.groupby([ "A" ]);
150-
// let new_data = [ [ 1, 3 ], [ 4, 6 ], [ 20, 40 ], [ 39, 78 ] ];
146+
let data = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 20, 30, 40 ], [ 39, 89, 78 ] ];
147+
let cols = [ "A", "B", "C" ];
148+
let df = new dfd.DataFrame(data, { columns: cols });
149+
let group_df = df.groupby([ "A" ]);
150+
let new_data = [ [ 1, 3 ], [ 4, 6 ], [ 20, 40 ], [ 39, 78 ] ];
151151

152-
// assert.deepEqual(group_df.col([ "C" ]).cummin().values, new_data);
153-
// });
152+
assert.deepEqual(group_df.col([ "C" ]).cummin().values, new_data);
153+
});
154154

155-
// it("cummulative prod for groupby", function () {
155+
it("cummulative prod for groupby", function () {
156156

157-
// let data = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 20, 30, 40 ], [ 39, 89, 78 ] ];
158-
// let cols = [ "A", "B", "C" ];
159-
// let df = new dfd.DataFrame(data, { columns: cols });
160-
// let group_df = df.groupby([ "A" ]);
161-
// let new_data = [ [ 1, 3 ], [ 4, 6 ], [ 20, 40 ], [ 39, 78 ] ];
157+
let data = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 20, 30, 40 ], [ 39, 89, 78 ] ];
158+
let cols = [ "A", "B", "C" ];
159+
let df = new dfd.DataFrame(data, { columns: cols });
160+
let group_df = df.groupby([ "A" ]);
161+
let new_data = [ [ 1, 3 ], [ 4, 6 ], [ 20, 40 ], [ 39, 78 ] ];
162162

163-
// assert.deepEqual(group_df.col([ "C" ]).cumprod().values, new_data);
164-
// });
163+
assert.deepEqual(group_df.col([ "C" ]).cumprod().values, new_data);
164+
});
165165
it("mean for groupby", function () {
166166

167167
let data = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 20, 30, 40 ], [ 39, 89, 78 ] ];
@@ -178,31 +178,31 @@ describe("groupby", function () {
178178
assert.deepEqual(group_df.col([ "B", "C" ]).mean().values, new_data);
179179
});
180180

181-
// it("printing multiindex table, example with cumsum operation for dataframe group by one column", function(){
182-
// let data = { 'A': [ 'foo', 'bar', 'foo', 'bar',
183-
// 'foo', 'bar', 'foo', 'foo' ],
184-
// 'B': [ 'one', 'one', 'two', 'three',
185-
// 'two', 'two', 'one', 'three' ],
186-
// 'C': [ 1, 3, 2, 4, 5, 2, 6, 7 ],
187-
// 'D': [ 3, 2, 4, 1, 5, 6, 7, 8 ] };
188-
189-
190-
// let df = new dfd.DataFrame(data);
191-
192-
// let grp = df.groupby([ "A" ]);
193-
// let rslt = [
194-
// [ 'foo', 1 ],
195-
// [ 'foo', 3 ],
196-
// [ 'foo', 8 ],
197-
// [ 'foo', 14 ],
198-
// [ 'foo', 21 ],
199-
// [ 'bar', 3 ],
200-
// [ 'bar', 7 ],
201-
// [ 'bar', 9 ]
202-
// ];
203-
// assert.deepEqual(grp.col([ "C" ]).cumsum().values, rslt);
204-
205-
// });
181+
it("printing multiindex table, example with cumsum operation for dataframe group by one column", function(){
182+
let data = { 'A': [ 'foo', 'bar', 'foo', 'bar',
183+
'foo', 'bar', 'foo', 'foo' ],
184+
'B': [ 'one', 'one', 'two', 'three',
185+
'two', 'two', 'one', 'three' ],
186+
'C': [ 1, 3, 2, 4, 5, 2, 6, 7 ],
187+
'D': [ 3, 2, 4, 1, 5, 6, 7, 8 ] };
188+
189+
190+
let df = new dfd.DataFrame(data);
191+
192+
let grp = df.groupby([ "A" ]);
193+
let rslt = [
194+
[ 'foo', 1 ],
195+
[ 'foo', 3 ],
196+
[ 'foo', 8 ],
197+
[ 'foo', 14 ],
198+
[ 'foo', 21 ],
199+
[ 'bar', 3 ],
200+
[ 'bar', 7 ],
201+
[ 'bar', 9 ]
202+
];
203+
assert.deepEqual(grp.col([ "C" ]).cumsum().values, rslt);
204+
205+
});
206206
it("printing multiindex table, example with cumsum operation for dataframe group by one column", function(){
207207
let data = { 'A': [ 'foo', 'bar', 'foo', 'bar',
208208
'foo', 'bar', 'foo', 'foo' ],

0 commit comments

Comments
 (0)