Skip to content

Commit 78fd1c9

Browse files
author
minjk-bl
committed
Edit pandas option able to ignore warnings
1 parent b0b1c19 commit 78fd1c9

File tree

2 files changed

+51
-13
lines changed

2 files changed

+51
-13
lines changed
Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<body>
2-
<div class="vp-grid-border-box vp-pandas-option-body">
2+
<div class="vp-grid-border-box vp-pandas-option-body vp-po-option">
33
<div class="vp-grid-col-110">
4-
<label for="min_rows" class="">Min/Max Rows</label>
4+
<label for="min_rows" class="">Min/Max rows</label>
55
<div>
66
<input type="number" id="min_rows" class="vp-input m vp-state" placeholder="10 (min)">
77
<input type="number" id="max_rows" class="vp-input m vp-state" placeholder="60 (max)">
@@ -13,8 +13,6 @@
1313
</div>
1414
<hr style="margin: 5px 0;">
1515
<div class="vp-grid-col-110">
16-
<label for="float_format" class="">Float format</label>
17-
<input type="number" class="vp-input vp-state" id="float_format" placeholder="None">
1816
<label for="precision" class="">Precision</label>
1917
<input type="number" class="vp-input vp-state" id="precision" placeholder="6">
2018
<label for="chop_threshold" class="">Chop threshold</label>
@@ -26,9 +24,29 @@
2624
<option value="False">False</option>
2725
</select>
2826
</div>
27+
<hr style="margin: 5px 0;">
28+
<label class="mt5">
29+
<input type="checkbox" id="setDefault">
30+
<span title="Set pandas options to default.">Reset option</span>
31+
</label>
32+
</div>
33+
<hr style="margin: 5px 0;">
34+
<div class="vp-grid-border-box vp-po-warning">
35+
<div class="vp-grid-col-110">
36+
<label for="filter_warning" class="">Filter warning</label>
37+
<select id="filter_warning" class="vp-select vp-state">
38+
<option value="">Select option...</option>
39+
<option value="default">Default (default)</option>
40+
<option value="error">Error</option>
41+
<option value="ignore">Ignore</option>
42+
<option value="always">Always</option>
43+
<option value="module">Module</option>
44+
<option value="once">Once</option>
45+
</select>
46+
</div>
47+
<label class="mt5">
48+
<input type="checkbox" id="resetWarning">
49+
<span title="Reset warning option.">Reset warning</span>
50+
</label>
2951
</div>
30-
<label class="mt5">
31-
<input type="checkbox" id="setDefault">
32-
<span title="Set chart setting to default.">Set Default</span>
33-
</label>
3452
</body>

visualpython/js/m_apps/PandasOption.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ define([
3333
this.config.checkModules = ['pd'];
3434

3535
this.state = {
36+
filter_warning: '',
3637
min_rows: '',
3738
max_rows: '',
3839
max_cols: '',
3940
max_colwidth: '',
40-
float_format: '',
4141
precision: '',
4242
chop_threshold: '',
4343
expand_frame_repr: '',
@@ -56,10 +56,23 @@ define([
5656

5757
if (checked) {
5858
// disable input
59-
$(that.wrapSelector('.vp-pandas-option-body input')).prop('disabled', true);
59+
$(that.wrapSelector('.vp-po-option input:not([type="checkbox"])')).prop('disabled', true);
6060
} else {
6161
// enable input
62-
$(that.wrapSelector('.vp-pandas-option-body input')).prop('disabled', false);
62+
$(that.wrapSelector('.vp-po-option input:not([type="checkbox"])')).prop('disabled', false);
63+
}
64+
});
65+
66+
// setting popup - reset warning
67+
$(this.wrapSelector('#resetWarning')).on('change', function() {
68+
let checked = $(this).prop('checked');
69+
70+
if (checked) {
71+
// disable input
72+
$(that.wrapSelector('.vp-po-warning input:not([type="checkbox"])')).prop('disabled', true);
73+
} else {
74+
// enable input
75+
$(that.wrapSelector('.vp-po-warning input:not([type="checkbox"])')).prop('disabled', false);
6376
}
6477
});
6578
}
@@ -81,15 +94,22 @@ define([
8194
let code = [];
8295

8396
let setDefault = $(this.wrapSelector('#setDefault')).prop('checked');
97+
let resetWarning = $(this.wrapSelector('#resetWarning')).prop('checked');
8498
if (setDefault == true) {
8599
// Object.keys(this.state).forEach((key) => {
86100
// code.push(com_util.formatString("pd.reset_option('display.{0}')", key));
87101
// })
88102
code.push("pd.reset_option('^display')");
89-
} else {
103+
} else if (resetWarning) {
104+
code.push("import warnings\nwarnings.resetwarnings()");
105+
} else{
90106
Object.keys(this.state).forEach((key) => {
91107
if (that.state[key] && that.state[key] != '') {
92-
code.push(com_util.formatString("pd.set_option('display.{0}', {1})", key, that.state[key]));
108+
if (key === 'filter_warning') {
109+
code.push(com_util.formatString("import warnings\nwarnings.simplefilter(action='{0}', category=Warning)", that.state[key]));
110+
} else {
111+
code.push(com_util.formatString("pd.set_option('display.{0}', {1})", key, that.state[key]));
112+
}
93113
}
94114
})
95115
}

0 commit comments

Comments
 (0)