Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion danfojs-browser/lib/bundle.js

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions danfojs-browser/lib/bundle.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@
* =============================================================================
*/

/**
* @license
* Copyright 2021 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* =============================================================================
*/

/**
* @license Complex.js v2.0.11 11/02/2016
*
Expand Down
2 changes: 1 addition & 1 deletion danfojs-browser/lib/bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion danfojs-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"types"
],
"dependencies": {
"@tensorflow/tfjs": "3.3.0",
"@tensorflow/tfjs": "3.6.0",
"mathjs": "7.5.1",
"table": "^5.4.6",
"xlsx": "^0.16.7"
Expand Down
2 changes: 1 addition & 1 deletion danfojs-browser/src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Utils {

// Returns if a value is an object
__is_object(value) {
return value && typeof value === "object" && value.constructor === Object;
return value && typeof value === "object" && value.constructor && value.constructor.name === "Object";
}

// Returns if a value is null
Expand Down
72 changes: 36 additions & 36 deletions danfojs-browser/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -894,66 +894,66 @@
readdirp "^2.2.1"
upath "^1.1.1"

"@tensorflow/tfjs-backend-cpu@3.3.0":
version "3.3.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-3.3.0.tgz#aa0a3ed2c6237a6e0c169678c5bd4b5a88766b1c"
integrity sha512-DLctv+PUZni26kQW1hq8jwQQ8u+GGc/p764WQIC4/IDagGtfGAUW1mHzWcTxtni2l4re1VrwE41ogWLhv4sGHg==
"@tensorflow/tfjs-backend-cpu@3.6.0":
version "3.6.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-cpu/-/tfjs-backend-cpu-3.6.0.tgz#4e64a7cf1c33b203f71f8f77cd7b0ac1ef25a871"
integrity sha512-ZpAs17hPdKXadbtNjAsymYUILe8V7+pY4fYo8j25nfDTW/HfBpyAwsHPbMcA/n5zyJ7ZJtGKFcCUv1sl24KL1Q==
dependencies:
"@types/seedrandom" "2.4.27"
seedrandom "2.4.3"

"@tensorflow/tfjs-backend-webgl@3.3.0":
version "3.3.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-3.3.0.tgz#29dd665f6a856c9defcb9108164f845e1fdcd02e"
integrity sha512-GWCtXbrjPTyye3ooId9GlcNDwnIMskZarUpNIQ5g/zeISLfwEQoutA/UqJF+HzuEHgGMsWFkmaO3xKVT7UMpdg==
"@tensorflow/tfjs-backend-webgl@3.6.0":
version "3.6.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-backend-webgl/-/tfjs-backend-webgl-3.6.0.tgz#1ea1a73abea8d6324fd81aedf7f187ab6eb73692"
integrity sha512-zp7l4TmD1khgeSux/Ujaaj8M/v+e8JVIKjOci6HCGaeMNrn74lTSH9oqGPWKUCmpZME17/V0LfRHK34ddmrPSA==
dependencies:
"@tensorflow/tfjs-backend-cpu" "3.3.0"
"@tensorflow/tfjs-backend-cpu" "3.6.0"
"@types/offscreencanvas" "~2019.3.0"
"@types/seedrandom" "2.4.27"
"@types/webgl-ext" "0.0.30"
"@types/webgl2" "0.0.5"
seedrandom "2.4.3"

"@tensorflow/tfjs-converter@3.3.0":
version "3.3.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-3.3.0.tgz#d9f2ffd0fbdbb47c07d5fd7c3e5dc180cff317aa"
integrity sha512-k57wN4yelePhmO9orcT/wzGMIuyedrMpVtg0FhxpV6BQu0+TZ/ti3W4Kb97GWJsoHKXMoing9SnioKfVnBW6hw==
"@tensorflow/tfjs-converter@3.6.0":
version "3.6.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-converter/-/tfjs-converter-3.6.0.tgz#32b3ff31b47e29630a82e30fbe01708facad7fd6"
integrity sha512-9MtatbTSvo3gpEulYI6+byTA3OeXSMT2lzyGAegXO9nMxsvjR01zBvlZ5SmsNyecNh6fMSzdL2+cCdQfQtsIBg==

"@tensorflow/tfjs-core@3.3.0":
version "3.3.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-3.3.0.tgz#3d26bd03cb58e0ecf46c96d118c39c4a90b7f5ed"
integrity sha512-6G+LcCiQBl4Kza5mDbWbf8QSWBTW3l7SDjGhQzMO1ITtQatHzxkuHGHcJ4CTUJvNA0JmKf4QJWOvlFqEmxwyLQ==
"@tensorflow/tfjs-core@3.6.0":
version "3.6.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-core/-/tfjs-core-3.6.0.tgz#6b4d8175790bdff78868eabe6adc6442eb4dc276"
integrity sha512-bb2c3zwK4SgXZRvkTiC7EhCpWbCGp0GMd+1/3Vo2/Z54jiLB/h3sXIgHQrTNiWwhKPtst/xxA+MsslFlvD0A5w==
dependencies:
"@types/offscreencanvas" "~2019.3.0"
"@types/seedrandom" "2.4.27"
"@types/webgl-ext" "0.0.30"
node-fetch "~2.6.1"
seedrandom "2.4.3"

"@tensorflow/tfjs-data@3.3.0":
version "3.3.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-data/-/tfjs-data-3.3.0.tgz#ba943bd6a486fa4cb3ca312c12646ea4dcf6cce4"
integrity sha512-0x28tRe6RJu5GmYq3IYN2GNnOgXU0nY+o6zZrlijkK+W3vjSTJlZzaBSifoeD6J8gzVpjs8W8qd/JKHQ1MQp8w==
"@tensorflow/tfjs-data@3.6.0":
version "3.6.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-data/-/tfjs-data-3.6.0.tgz#af2f03cffb75ad8e4c2f46e192e392d9b7f977ed"
integrity sha512-5KU7fnU7cj/opb4aCNDoW4qma64ggDwI0PCs5KEO41T3waVHDLk6bjlFlBVRdjfZqvM0K6EfWEyoiXzdvz/Ieg==
dependencies:
"@types/node-fetch" "^2.1.2"
node-fetch "~2.6.1"

"@tensorflow/tfjs-layers@3.3.0":
version "3.3.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-layers/-/tfjs-layers-3.3.0.tgz#d2097c5b22ec12e5fdbe470a88ca0a34a95ca11f"
integrity sha512-qO+TL2I29vWUiuFcQJXNyayWFYagwR+SIfbex8p5jjYaCGHGwE5GQcrH+ngoCgKZxm5tdMvYJsJPnih2M3fYzQ==
"@tensorflow/tfjs-layers@3.6.0":
version "3.6.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs-layers/-/tfjs-layers-3.6.0.tgz#5358af559fc8baed304b3e567319fe93f1aa46a6"
integrity sha512-B7EHwAT6KFqhKzdf0e2Sr6haj9qpqpyEATV8OCPHdk+g8z2AGXOLlFfbgW6vCMjy1wb5jzYqCyZDoY3EWdgJAw==

"@tensorflow/tfjs@3.3.0":
version "3.3.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-3.3.0.tgz#db92099dd48c0eb1c1673f705125d2b57496a1a3"
integrity sha512-xo22GCUCGcPtNGIdDpLPrp9ms3atXmzX8AF4y3aIBEwK5KlvGe+ZhcoQ2xEOCPQGBr7NB7AO6rwT8gRoziAHVg==
dependencies:
"@tensorflow/tfjs-backend-cpu" "3.3.0"
"@tensorflow/tfjs-backend-webgl" "3.3.0"
"@tensorflow/tfjs-converter" "3.3.0"
"@tensorflow/tfjs-core" "3.3.0"
"@tensorflow/tfjs-data" "3.3.0"
"@tensorflow/tfjs-layers" "3.3.0"
"@tensorflow/tfjs@3.6.0":
version "3.6.0"
resolved "https://registry.yarnpkg.com/@tensorflow/tfjs/-/tfjs-3.6.0.tgz#e65956cd40c96523e3f5ec7a58a4bef9ef5e349c"
integrity sha512-uLDMDzyRkJa3fYBeR6etQTFD/t+nkQIH/DznL9hxmYoIYG8PigY2gcrc482TAvsdhiuvxCZ9rl5SyDtP93MvxQ==
dependencies:
"@tensorflow/tfjs-backend-cpu" "3.6.0"
"@tensorflow/tfjs-backend-webgl" "3.6.0"
"@tensorflow/tfjs-converter" "3.6.0"
"@tensorflow/tfjs-core" "3.6.0"
"@tensorflow/tfjs-data" "3.6.0"
"@tensorflow/tfjs-layers" "3.6.0"
argparse "^1.0.10"
chalk "^4.1.0"
core-js "3"
Expand Down
86 changes: 23 additions & 63 deletions danfojs-node/dist/core/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -924,74 +924,34 @@ class DataFrame extends _generic.default {
}

groupby(col) {
let len = this.shape[0];
let column_names = this.column_names;
let col_dict = {};
let key_column = null;
let col_index = col.map(val => column_names.indexOf(val));
let col_dtype = this.dtypes.filter((val, index) => {
const len = this.shape[0];
const column_names = this.column_names;
const col_index = col.map(val => column_names.indexOf(val));
const col_dtype = this.dtypes.filter((val, index) => {
return col_index.includes(index);
});
const self = this;
const data = col.map(column_name => {
if (!column_names.includes(column_name)) throw new Error(`column ${column_name} does not exist`);
const [column_data, _] = (0, _indexing.indexLoc)(self, {
rows: [`0:${len}`],
columns: [`${column_name}`],
type: "loc"
});
return column_data;
});
const unique_columns = data.map(column_data => utils.__unique(column_data));

if (col.length == 2) {
if (column_names.includes(col[0])) {
var [data1, col_name1] = (0, _indexing.indexLoc)(this, {
rows: [`0:${len}`],
columns: [`${col[0]}`],
type: "loc"
});
} else {
throw new Error(`column ${col[0]} does not exist`);
}

if (column_names.includes(col[1])) {
var [data2, col_name2] = (0, _indexing.indexLoc)(this, {
rows: [`0:${len}`],
columns: [`${col[1]}`],
type: "loc"
});
} else {
throw new Error(`column ${col[1]} does not exist`);
}

key_column = [col[0], col[1]];

var column_1_Unique = utils.__unique(data1);

var column_2_unique = utils.__unique(data2);

for (var i = 0; i < column_1_Unique.length; i++) {
let col_value = column_1_Unique[i];
col_dict[col_value] = {};

for (var j = 0; j < column_2_unique.length; j++) {
let col2_value = column_2_unique[j];
col_dict[col_value][col2_value] = [];
}
}
} else {
if (column_names.includes(col[0])) {
var [data1, col_name1] = (0, _indexing.indexLoc)(this, {
rows: [`0:${len}`],
columns: [`${col[0]}`],
type: "loc"
});
} else {
throw new Error(`column ${col[0]} does not exist`);
}

key_column = [col[0]];

var column_Unique = utils.__unique(data1);

for (let i = 0; i < column_Unique.length; i++) {
let col_value = column_Unique[i];
col_dict[col_value] = [];
}
function getRecursiveDict(uniq_columns) {
const first_uniq_columns = uniq_columns[0];
const remaining_columns = uniq_columns.slice(1);
const c_dict = {};
if (!remaining_columns.length) first_uniq_columns.forEach(col_value => c_dict[col_value] = []);else first_uniq_columns.forEach(col_value => c_dict[col_value] = getRecursiveDict(remaining_columns));
return c_dict;
}

let groups = new _groupby.GroupBy(col_dict, key_column, this.values, column_names, col_dtype).group();
return groups;
const col_dict = getRecursiveDict(unique_columns);
return new _groupby.GroupBy(col_dict, col, this.values, column_names, col_dtype).group();
}

column(col_name) {
Expand Down
Loading