Skip to content

Commit 184d58d

Browse files
committed
[groupby.js][s]: update groupby to work on data without specifying the columns
1 parent 55063b9 commit 184d58d

1 file changed

Lines changed: 2 additions & 62 deletions

File tree

danfojs-node/src/core/groupby.js

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { DataFrame } from "./frame";
22
import { Utils } from "./utils";
3-
import { concat } from "./concat.js";
43
import { Series } from "./series";
5-
import { data } from "@tensorflow/tfjs-node";
64
const utils = new Utils;
75

86
/**
@@ -350,7 +348,6 @@ export class GroupBy {
350348

351349
to_DataFrame(key_col, col, data, ops){
352350

353-
// console.log(data);
354351
if (key_col.length == 2){
355352
let df_data = [];
356353
for (let key_1 in data){
@@ -445,62 +442,6 @@ export class GroupBy {
445442
}
446443
}
447444

448-
// apply(kwargs){
449-
// let isCol;
450-
// let column_names;
451-
// let df_data;
452-
// let callable = kwargs["callable"];
453-
// if (kwargs["isCol"]) {
454-
// isCol = kwargs['isCol'];
455-
// } else {
456-
// isCol = false;
457-
// }
458-
459-
// let data = [];
460-
// if (isCol && this.group_col) {
461-
// column_names = this.selected_column;
462-
// df_data = this.group_col;
463-
// console.log("here");
464-
// } else {
465-
// column_names = this.column_name;
466-
// df_data = this.data_tensors;
467-
// }
468-
// if (this.key_col.length == 2) {
469-
// for (let key in this.data_tensors) {
470-
// for (let key2 in this.data_tensors[key]) {
471-
// let callable_rslt = callable(this.data_tensors[key][key2]);
472-
// if (callable_rslt instanceof DataFrame) {
473-
// data.push(callable_rslt);
474-
// } else {
475-
// data.push(callable_rslt.values);
476-
// }
477-
// }
478-
// }
479-
// } else {
480-
// for (let key in df_data) {
481-
// let callable_rslt = isCol ? callable(df_data[key][0]) : callable(df_data[key]);
482-
// if (callable_rslt instanceof DataFrame) {
483-
// data.push(callable_rslt);
484-
// } else {
485-
// if (Array.isArray(callable_rslt.values)) {
486-
// data.push(callable_rslt.values);
487-
// } else {
488-
// data.push([callable_rslt]);
489-
// }
490-
491-
// }
492-
// }
493-
// }
494-
495-
// if (data[0] instanceof DataFrame) {
496-
// return concat({ df_list: data, axis: 0 });
497-
// } else {
498-
// return new DataFrame(data, { columns: column_names });
499-
// }
500-
// }
501-
502-
// }
503-
504445
apply(callable){
505446
let df_data;
506447
let column;
@@ -509,6 +450,7 @@ export class GroupBy {
509450
let col_gp = this.col(column);
510451
df_data = col_gp.group_col;
511452
} else {
453+
column = this.group_col_name;
512454
df_data = this.group_col;
513455
}
514456
let data = [];
@@ -546,7 +488,6 @@ export class GroupBy {
546488
if (callable_rslt instanceof Series) {
547489
count_group[key].push(callable_rslt.values);
548490
} else {
549-
console.log(callable_rslt);
550491
count_group[key].push(callable_rslt);
551492
}
552493

@@ -555,8 +496,7 @@ export class GroupBy {
555496

556497
}
557498
}
558-
this.to_DataFrame(this.key_col, column, count_group, "apply").print();
559-
return count_group;
499+
return this.to_DataFrame(this.key_col, column, count_group, "apply");
560500
}
561501

562502
}

0 commit comments

Comments
 (0)