Skip to content

Commit 9ca01bf

Browse files
author
minjk-bl
committed
Fix set_index and reset_index bug on Frame app
1 parent c928f64 commit 9ca01bf

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

js/m_apps/Frame.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,12 @@ define([
663663
});
664664
}
665665

666-
// Render Inner popup page
666+
/**
667+
* Render Inner popup page
668+
* @param {*} type
669+
* @param {*} targetLabel
670+
* @returns
671+
*/
667672
renderAddPage = function(type, targetLabel = '') {
668673
var content = new com_String();
669674
content.appendFormatLine('<div class="{0}">', 'vp-inner-popup-addpage');
@@ -682,7 +687,9 @@ define([
682687
content.appendFormatLine('<td><select class="{0}">', 'vp-inner-popup-addtype');
683688
content.appendFormatLine('<option value="{0}">{1}</option>', 'value', 'Value');
684689
content.appendFormatLine('<option value="{0}">{1}</option>', 'calculation', 'Calculation');
685-
content.appendFormatLine('<option value="{0}">{1}</option>', 'replace', 'Replace');
690+
if (type == 'replace') {
691+
content.appendFormatLine('<option value="{0}">{1}</option>', 'replace', 'Replace');
692+
}
686693
if (type == 'column' || type == 'replace') {
687694
content.appendFormatLine('<option value="{0}">{1}</option>', 'subset', 'Subset');
688695
}
@@ -1245,6 +1252,17 @@ define([
12451252
code.appendFormat("{0} = vp_drop_outlier({1}, {2})", tempObj, tempObj, selectedName);
12461253
}
12471254
break;
1255+
case FRAME_EDIT_TYPE.LABEL_ENCODING:
1256+
if (axis == FRAME_AXIS.COLUMN) {
1257+
let encodedColName = this.state.selected.map(col=> {
1258+
if (col.code !== col.label) {
1259+
return com_util.formatString("'{0}'", col.label + '_label');
1260+
}
1261+
return col.label + '_label'
1262+
}).join(',');
1263+
code.appendFormat("{0}[{1}] = pd.Categorical({2}[{3}]).codes", tempObj, encodedColName, tempObj, selectedName);
1264+
}
1265+
break;
12481266
case FRAME_EDIT_TYPE.ONE_HOT_ENCODING:
12491267
if (axis == FRAME_AXIS.COLUMN) {
12501268
code.appendFormat("{0} = pd.get_dummies(data={1}, columns=[{2}])", tempObj, tempObj, selectedName);
@@ -1347,7 +1365,7 @@ define([
13471365

13481366
var code = new com_String();
13491367
code.appendLine(codeStr);
1350-
code.appendFormat("{0}[{1}:{2}].to_json(orient='{3}')", tempObj, prevLines, lines, 'split');
1368+
code.appendFormat("{0}.iloc[{1}:{2}].to_json(orient='{3}')", tempObj, prevLines, lines, 'split');
13511369

13521370
this.loading = true;
13531371
vpKernel.execute(code.toString()).then(function(resultObj) {
@@ -1490,7 +1508,7 @@ define([
14901508
}
14911509
}).catch(function(resultObj) {
14921510
let { result, type, msg } = resultObj;
1493-
vpLog.display(VP_LOG_TYPE.ERROR, result.ename + ': ' + result.evalue, msg);
1511+
vpLog.display(VP_LOG_TYPE.ERROR, result.ename + ': ' + result.evalue, msg, code.toString());
14941512
com_util.renderAlertModal(result.ename + ': ' + result.evalue);
14951513
that.loading = false;
14961514
});
@@ -1579,6 +1597,8 @@ define([
15791597
DROP_OUT: 11,
15801598

15811599
ONE_HOT_ENCODING: 6,
1600+
LABEL_ENCODING: 12,
1601+
15821602
SET_IDX: 7,
15831603
RESET_IDX: 8,
15841604
REPLACE: 9,

0 commit comments

Comments
 (0)