Skip to content

Commit eec59ea

Browse files
committed
fix update bug in drop
1 parent a978fc8 commit eec59ea

1 file changed

Lines changed: 6 additions & 41 deletions

File tree

danfojs/src/core/frame.js

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class DataFrame extends Ndframe {
8989
}
9090
return col_idx
9191
});
92-
92+
9393
this.col_data.forEach((col, idx) => {
9494
if (!index.includes(idx)) {
9595
new_col_data[self.column_names[idx]] = col
@@ -107,7 +107,7 @@ export class DataFrame extends Ndframe {
107107
} else {
108108
let old_cols = self.columns
109109
let new_columns = Object.keys(new_col_data)
110-
this.__update_frame_in_place(null, null, new_col_data, null,new_dtype)
110+
this.__update_frame_in_place(null, null, new_col_data, null, new_dtype)
111111
this.__set_col_property(self, self.col_data, new_columns, old_cols)
112112

113113
}
@@ -696,7 +696,8 @@ export class DataFrame extends Ndframe {
696696
let df = new DataFrame([...this.values],
697697
{
698698
columns: [...this.column_names],
699-
index: this.index, dtypes: this.dtypes
699+
index: this.index,
700+
dtypes: this.dtypes
700701
})
701702
return df
702703
}
@@ -717,7 +718,6 @@ export class DataFrame extends Ndframe {
717718
}
718719

719720
/**
720-
* Generate a new DataFrame with the specified index.
721721
* Set the DataFrame index (row labels) using an array of the same length.
722722
* @param {kwargs} {index: Array of new index values}
723723
*/
@@ -861,9 +861,8 @@ export class DataFrame extends Ndframe {
861861
})
862862

863863
if (utils.__key_in_object(kwargs, "inplace") && kwargs['inplace'] == true) {
864-
this.data = new_row_data
865-
this.index_arr = sorted_index
866-
return null
864+
this.__update_frame_in_place(new_row_data, null, null, sorted_index, null)
865+
867866
} else {
868867
let df = new DataFrame(new_row_data, { columns: this.column_names, index: sorted_index, dtype: this.dtypes })
869868
return df
@@ -1094,17 +1093,14 @@ export class DataFrame extends Ndframe {
10941093
groupby(col) {
10951094

10961095
let len = this.shape[0]
1097-
10981096
let column_names = this.column_names
10991097
let col_dict = {};
11001098
let key_column = null;
11011099

11021100
if (col.length == 2) {
1103-
11041101
if (column_names.includes(col[0])) {
11051102
// eslint-disable-next-line no-unused-vars
11061103
var [data1, col_name1] = indexLoc(this, { "rows": [`0:${len}`], "columns": [`${col[0]}`], "type": "loc" });
1107-
11081104
}
11091105
else {
11101106
throw new Error(`column ${col[0]} does not exist`);
@@ -1307,37 +1303,6 @@ export class DataFrame extends Ndframe {
13071303
}
13081304

13091305

1310-
1311-
// let new_row_data = []
1312-
// let row_data = this.values;
1313-
// let columns = this.column_names;
1314-
1315-
// row_data.map(arr=>{
1316-
// let temp_arr = []
1317-
// arr.map(val=>{
1318-
// if (isNaN(val) && typeof val != "string" ){
1319-
// temp_arr.push(true)
1320-
// }else{
1321-
// temp_arr.push(false)
1322-
// }
1323-
// })
1324-
// new_row_data.push(temp_arr)
1325-
// })
1326-
1327-
// // for (let i = 0; i < values.length; i++) {
1328-
// // let temp_data = []
1329-
// // let row_value = values[i]
1330-
// // for (let j = 0; j < row_value.length; j++) {
1331-
1332-
// // let val = row_value[j] == 0 ? true : !row_value[j]
1333-
// // temp_data.push(val)
1334-
// // }
1335-
// // data.push(temp_data);
1336-
// // }
1337-
1338-
// return new DataFrame(new_row_data, { columns: columns, index: this.index })
1339-
1340-
13411306
/**
13421307
* Obtain index containing nan values
13431308
* @return Array list (int)

0 commit comments

Comments
 (0)