@@ -61,12 +61,9 @@ define([
61
61
}
62
62
63
63
// numpy.dtype or python type
64
- this . astypeList = [
65
- 'datetime64' ,
66
- 'int' , 'int32' , 'int64' ,
67
- 'float' , 'float64' ,
68
- 'object' , 'category' ,
69
- 'bool' , 'str'
64
+ this . astypeList = [
65
+ 'object' , 'int64' , 'float64' , 'bool' ,
66
+ 'datetime64[ns]' , 'timedelta[ns]' , 'category'
70
67
] ;
71
68
72
69
// {
@@ -1021,28 +1018,29 @@ define([
1021
1018
$ ( that . wrapSelector ( '.vp-inner-popup-isedgechanged' ) ) . val ( "false" ) ;
1022
1019
1023
1020
let code = new com_String ( ) ;
1024
- code . appendFormatLine ( "_out, _bins = pd.cut({0}[{1}], bins={2}, right={3}, labels=False, retbins=True)"
1021
+ code . appendFormatLine ( "_out, _bins = pd.cut({0}[{1}], bins={2}, right={3}, retbins=True)"
1025
1022
, this . state . tempObj , this . state . selected [ 0 ] . code , binsCount , right ?'True' :'False' ) ;
1026
- code . append ( "_vp_print({'labels': _out.unique(), ' edges': list(_bins)})" ) ;
1023
+ code . append ( "_vp_print({'edges': list(_bins)})" ) ;
1027
1024
vpKernel . execute ( code . toString ( ) ) . then ( function ( resultObj ) {
1028
1025
let { result } = resultObj ;
1029
- let { labels , edges } = JSON . parse ( result ) ;
1026
+ let { edges } = JSON . parse ( result ) ;
1030
1027
1028
+ let labelLength = edges . length - 1 ;
1031
1029
let edgeTbody = new com_String ( ) ;
1032
- labels && labels . forEach ( ( label , idx ) => {
1030
+ for ( let idx = 0 ; idx < labelLength ; idx ++ ) {
1033
1031
let leftDisabled = 'disabled' ;
1034
1032
let rightDisabled = '' ;
1035
- if ( idx === ( labels . length - 1 ) ) {
1033
+ if ( idx === ( labelLength - 1 ) ) {
1036
1034
rightDisabled = 'disabled' ;
1037
1035
}
1038
1036
edgeTbody . append ( '<tr>' ) ;
1039
- edgeTbody . appendFormatLine ( '<td><input type="text" class="vp-input m vp-inner-popup-label" data-idx="{0}" value="{1}"/></td>' , idx , label ) ;
1037
+ edgeTbody . appendFormatLine ( '<td><input type="text" class="vp-input m vp-inner-popup-label" data-idx="{0}" value="{1}"/></td>' , idx , idx ) ;
1040
1038
edgeTbody . appendLine ( '<td>:</td>' ) ;
1041
1039
edgeTbody . appendFormatLine ( '<td><input type="number" class="vp-input m vp-inner-popup-left-edge" data-idx="{0}" value="{1}" {2}/></td>' , idx , edges [ idx ] , leftDisabled ) ;
1042
1040
edgeTbody . appendLine ( '<td>~</td>' ) ;
1043
1041
edgeTbody . appendFormatLine ( '<td><input type="number" class="vp-input m vp-inner-popup-right-edge" data-idx="{0}" value="{1}" {2}/></td>' , idx + 1 , edges [ idx + 1 ] , rightDisabled ) ;
1044
1042
edgeTbody . append ( '</tr>' ) ;
1045
- } ) ;
1043
+ }
1046
1044
$ ( that . wrapSelector ( '.vp-inner-popup-range-table tbody' ) ) . html ( edgeTbody . toString ( ) ) ;
1047
1045
1048
1046
// label change event
@@ -1065,7 +1063,7 @@ define([
1065
1063
} ) ;
1066
1064
1067
1065
} ) . catch ( function ( errObj ) {
1068
- // TODO:
1066
+ vpLog . display ( VP_LOG_TYPE . ERROR , errObj ) ;
1069
1067
} ) ;
1070
1068
}
1071
1069
@@ -1333,8 +1331,8 @@ define([
1333
1331
if ( type === 'column' ) {
1334
1332
content . appendLine ( '<tr><th><label>Add type</label></th>' ) ;
1335
1333
content . appendFormatLine ( '<td><select class="{0}">' , 'vp-inner-popup-addtype' ) ;
1336
- content . appendFormatLine ( '<option value="{0}">{1}</option>' , 'variable ' , 'Variable ' ) ;
1337
- content . appendFormatLine ( '<option value="{0}">{1}</option>' , 'value ' , 'Value ' ) ;
1334
+ content . appendFormatLine ( '<option value="{0}">{1}</option>' , 'calculate ' , 'Calculate ' ) ;
1335
+ content . appendFormatLine ( '<option value="{0}">{1}</option>' , 'replace ' , 'Replace ' ) ;
1338
1336
content . appendFormatLine ( '<option value="{0}">{1}</option>' , 'condition' , 'Condition' ) ;
1339
1337
content . appendFormatLine ( '<option value="{0}">{1}</option>' , 'apply' , 'Apply' ) ;
1340
1338
content . appendLine ( '</select></td></tr>' ) ;
@@ -1344,8 +1342,8 @@ define([
1344
1342
1345
1343
content . appendLine ( '<hr style="margin: 5px 0px;"/>' ) ;
1346
1344
1347
- // tab 1. variable
1348
- content . appendFormatLine ( '<div class="{0} {1}">' , 'vp-inner-popup-tab' , 'variable ' ) ;
1345
+ // tab 1. calculate
1346
+ content . appendFormatLine ( '<div class="{0} {1}">' , 'vp-inner-popup-tab' , 'calculate ' ) ;
1349
1347
content . appendLine ( '<table class="vp-tbl-gap5"><colgroup><col width="110px"><col width="*"><col width="15px"></colgroup>' ) ;
1350
1348
content . appendLine ( '<tr class="vp-inner-popup-value-row">' ) ;
1351
1349
content . appendFormatLine ( '<th><select class="{0}"><option value="variable">Variable</option><option value="column">Column</option></select></th>' , 'vp-inner-popup-vartype' ) ;
@@ -1368,8 +1366,8 @@ define([
1368
1366
content . appendLine ( '</table>' ) ;
1369
1367
content . appendLine ( '</div>' ) ; // end of vp-inner-popup-tab value
1370
1368
1371
- // tab 2. value
1372
- content . appendFormatLine ( '<div class="{0} {1}" style="display:none;">' , 'vp-inner-popup-tab' , 'value ' ) ;
1369
+ // tab 2. replace
1370
+ content . appendFormatLine ( '<div class="{0} {1}" style="display:none;">' , 'vp-inner-popup-tab' , 'replace ' ) ;
1373
1371
content . appendFormatLine ( '<div class="{0}">' , 'vp-grid-col-120' ) ;
1374
1372
content . appendLine ( '<label class="vp-orange-text">Target column</label>' ) ;
1375
1373
content . appendFormatLine ( '<select class="vp-select {0}">' , 'vp-inner-popup-value-col-list' ) ;
@@ -1718,15 +1716,15 @@ define([
1718
1716
content . appendLine ( '</td></tr>' ) ;
1719
1717
content . appendLine ( '<tr><th><label>Replace type</label></th>' ) ;
1720
1718
content . appendFormatLine ( '<td><select class="{0}">' , 'vp-inner-popup-replacetype' ) ;
1721
- content . appendFormatLine ( '<option value="{0}">{1}</option>' , 'value ' , 'Value ' ) ;
1719
+ content . appendFormatLine ( '<option value="{0}">{1}</option>' , 'replace ' , 'Replace ' ) ;
1722
1720
content . appendFormatLine ( '<option value="{0}">{1}</option>' , 'condition' , 'Condition' ) ;
1723
1721
content . appendLine ( '</select></td></tr>' ) ;
1724
1722
content . appendLine ( '</table>' ) ;
1725
1723
content . appendLine ( '</div>' ) ; // end of vp-inner-popup-header
1726
1724
1727
1725
content . appendLine ( '<hr style="margin: 5px 0px;"/>' ) ;
1728
- // replace page - 1. value
1729
- content . appendFormatLine ( '<div class="{0}">' , 'vp-inner-popup-tab value ' ) ;
1726
+ // replace page - 1. replace
1727
+ content . appendFormatLine ( '<div class="{0}">' , 'vp-inner-popup-tab replace ' ) ;
1730
1728
content . appendFormatLine ( '<label><input type="checkbox" class="{0}"/><span>{1}</span></label>' , 'vp-inner-popup-use-regex' , 'Use Regular Expression' ) ;
1731
1729
content . appendLine ( '<br/><br/>' ) ;
1732
1730
content . appendFormatLine ( '<div class="{0}">' , 'vp-inner-popup-replace-table' ) ;
@@ -2348,13 +2346,13 @@ define([
2348
2346
}
2349
2347
var tab = $ ( this . wrapSelector ( '.vp-inner-popup-addtype' ) ) . val ( ) ;
2350
2348
if ( type === FRAME_EDIT_TYPE . ADD_ROW ) {
2351
- tab = 'variable ' ;
2349
+ tab = 'calculate ' ;
2352
2350
}
2353
2351
content [ 'addtype' ] = tab ;
2354
- if ( tab == 'variable ' ) {
2352
+ if ( tab == 'calculate ' ) {
2355
2353
let values = [ ] ;
2356
2354
let opers = [ ] ;
2357
- $ ( this . wrapSelector ( '.vp-inner-popup-tab.variable tr.vp-inner-popup-value-row' ) ) . each ( ( idx , tag ) => {
2355
+ $ ( this . wrapSelector ( '.vp-inner-popup-tab.calculate tr.vp-inner-popup-value-row' ) ) . each ( ( idx , tag ) => {
2358
2356
let varType = $ ( tag ) . find ( '.vp-inner-popup-vartype' ) . val ( ) ;
2359
2357
if ( varType === 'variable' ) {
2360
2358
let valueastext = $ ( tag ) . find ( '.vp-inner-popup-istext' ) . prop ( 'checked' ) ;
@@ -2371,7 +2369,7 @@ define([
2371
2369
} ) ;
2372
2370
content [ 'values' ] = values ;
2373
2371
content [ 'opers' ] = opers ;
2374
- } else if ( tab == 'value ' ) {
2372
+ } else if ( tab == 'replace ' ) {
2375
2373
content [ 'target' ] = $ ( this . wrapSelector ( '.vp-inner-popup-value-col-list option:selected' ) ) . data ( 'code' ) ;
2376
2374
var useregex = $ ( this . wrapSelector ( '.vp-inner-popup-use-regex' ) ) . prop ( 'checked' ) ;
2377
2375
content [ 'useregex' ] = useregex ;
@@ -2428,7 +2426,7 @@ define([
2428
2426
content [ 'name' ] = $ ( this . wrapSelector ( '.vp-inner-popup-input1' ) ) . data ( 'code' ) ;
2429
2427
var tab = $ ( this . wrapSelector ( '.vp-inner-popup-replacetype' ) ) . val ( ) ;
2430
2428
content [ 'replacetype' ] = tab ;
2431
- if ( tab == 'value ' ) {
2429
+ if ( tab == 'replace ' ) {
2432
2430
var useregex = $ ( this . wrapSelector ( '.vp-inner-popup-use-regex' ) ) . prop ( 'checked' ) ;
2433
2431
content [ 'useregex' ] = useregex ;
2434
2432
content [ 'list' ] = [ ] ;
@@ -2825,7 +2823,7 @@ define([
2825
2823
return '' ;
2826
2824
}
2827
2825
var tab = content . addtype ;
2828
- if ( tab == 'variable ' ) {
2826
+ if ( tab == 'calculate ' ) {
2829
2827
let values = [ ] ;
2830
2828
content [ 'values' ] && content [ 'values' ] . forEach ( ( val , idx ) => {
2831
2829
if ( idx > 0 ) {
@@ -2839,7 +2837,7 @@ define([
2839
2837
} else {
2840
2838
code . appendFormat ( "{0}[{1}] = {2}" , tempObj , content . name , valueStr ) ;
2841
2839
}
2842
- } else if ( tab == 'value ' ) {
2840
+ } else if ( tab == 'replace ' ) {
2843
2841
var replaceStr = new com_String ( ) ;
2844
2842
var targetName = content [ 'target' ] ;
2845
2843
var useRegex = content [ 'useregex' ] ;
@@ -2916,7 +2914,7 @@ define([
2916
2914
case FRAME_EDIT_TYPE . REPLACE :
2917
2915
var name = content . name ;
2918
2916
var tab = content . replacetype ;
2919
- if ( tab === 'value ' ) {
2917
+ if ( tab === 'replace ' ) {
2920
2918
var replaceStr = new com_String ( ) ;
2921
2919
var useRegex = content [ 'useregex' ] ;
2922
2920
content [ 'list' ] . forEach ( ( obj , idx ) => {
0 commit comments