Skip to content

Commit d79f48c

Browse files
author
minjk-bl
committed
Edit not to add condition if its target and operator is not selected
1 parent 722b2db commit d79f48c

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

visualpython/js/m_apps/Frame.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -710,10 +710,7 @@ define([
710710
return;
711711
}
712712
} else if (type === FRAME_EDIT_TYPE.REPLACE) {
713-
if (content.replacetype === 'condition' && content.value === '') {
714-
$(this.wrapSelector('.vp-inner-popup-input3')).focus();
715-
return;
716-
}
713+
;
717714
} else if (type === FRAME_EDIT_TYPE.FILL_NA) {
718715
if (content.method === 'value' && content.value === '') {
719716
$(this.wrapSelector('.vp-inner-popup-value')).focus();
@@ -3101,7 +3098,7 @@ define([
31013098
});
31023099
let valueStr = values.join(' ');
31033100
if (valueStr === "" || valueStr === "''") {
3104-
code.appendFormat("{0}[{1}] = np.NaN", tempObj, content.name);
3101+
code.appendFormat("{0}[{1}] = np.nan", tempObj, content.name);
31053102
} else {
31063103
code.appendFormat("{0}[{1}] = {2}", tempObj, content.name, valueStr);
31073104
}
@@ -3178,6 +3175,9 @@ define([
31783175
}
31793176
});
31803177
var value = com_util.convertToStr(content.value, content.valueastext);
3178+
if (value === '') {
3179+
value = 'np.nan';
3180+
}
31813181
code.appendFormat(", {0}] = {1}", content.name, value);
31823182
}
31833183
break;
@@ -3223,9 +3223,10 @@ define([
32233223
code.append(')');
32243224
} else if (tab === 'condition') {
32253225
code.appendFormat("{0}.loc[", tempObj);
3226+
var condCode = new com_String();
32263227
content['list'].forEach((obj, idx) => {
32273228
let { colName, oper, cond, condAsText, connector } = obj;
3228-
code.append('(');
3229+
condCode.append('(');
32293230

32303231
let colValue = tempObj;
32313232
if (colName && colName != '') {
@@ -3237,25 +3238,31 @@ define([
32373238
}
32383239
let condValue = com_util.convertToStr(cond, condAsText);
32393240
if (oper == 'contains') {
3240-
code.appendFormat('{0}.str.contains({1})', colValue, condValue);
3241+
condCode.appendFormat('{0}.str.contains({1})', colValue, condValue);
32413242
} else if (oper == 'not contains') {
3242-
code.appendFormat('~{0}.str.contains({1})', colValue, condValue);
3243+
condCode.appendFormat('~{0}.str.contains({1})', colValue, condValue);
32433244
} else if (oper == 'starts with') {
3244-
code.appendFormat('{0}.str.startswith({1})', colValue, condValue);
3245+
condCode.appendFormat('{0}.str.startswith({1})', colValue, condValue);
32453246
} else if (oper == 'ends with') {
3246-
code.appendFormat('{0}.str.endswith({1})', colValue, condValue);
3247+
condCode.appendFormat('{0}.str.endswith({1})', colValue, condValue);
32473248
} else if (oper == 'isnull()' || oper == 'notnull()') {
3248-
code.appendFormat('{0}.{1}', colValue, oper);
3249+
condCode.appendFormat('{0}.{1}', colValue, oper);
32493250
} else {
3250-
code.appendFormat('{0}{1}{2}', colValue, oper != ''?(' ' + oper):'', condValue != ''?(' ' + condValue):'');
3251+
condCode.appendFormat('{0}{1}{2}', colValue, oper != ''?(' ' + oper):'', condValue != ''?(' ' + condValue):'');
32513252
}
3252-
code.append(')');
3253+
condCode.append(')');
32533254
if (idx < (content['list'].length - 1)) {
3254-
code.append(connector);
3255+
condCode.append(connector);
32553256
}
32563257
});
3258+
if (condCode.toString() === '') {
3259+
condCode.append(':');
3260+
}
32573261
var value = com_util.convertToStr(content.value, content.valueastext);
3258-
code.appendFormat(", {0}] = {1}", content.name, value);
3262+
if (value === '') {
3263+
value = 'np.nan';
3264+
}
3265+
code.appendFormat("{0}, {1}] = {2}", condCode.toString(), content.name, value);
32593266
} else if (tab == 'apply') {
32603267
// code.appendFormat("{0}[{1}] = {2}[{3}].apply({4})", tempObj, content.name, tempObj, content.column, content.apply);
32613268
let lambdaCode = 'lambda x: ';

visualpython/js/m_apps/Subset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1742,7 +1742,7 @@ define([
17421742
var connector = i > 0 ? $(condList[i - 1]).find('.vp-oper-connect').val() : undefined;
17431743

17441744
// if no variable selected, pass
1745-
if (varName == "")
1745+
if (varName === "" || oper === "")
17461746
continue;
17471747
if (useCondition) {
17481748
rowSelection.append(connector);

0 commit comments

Comments
 (0)