@@ -61,12 +61,9 @@ define([
6161 }
6262
6363 // 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'
7067 ] ;
7168
7269 // {
@@ -1021,28 +1018,29 @@ define([
10211018 $ ( that . wrapSelector ( '.vp-inner-popup-isedgechanged' ) ) . val ( "false" ) ;
10221019
10231020 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)"
10251022 , 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)})" ) ;
10271024 vpKernel . execute ( code . toString ( ) ) . then ( function ( resultObj ) {
10281025 let { result } = resultObj ;
1029- let { labels , edges } = JSON . parse ( result ) ;
1026+ let { edges } = JSON . parse ( result ) ;
10301027
1028+ let labelLength = edges . length - 1 ;
10311029 let edgeTbody = new com_String ( ) ;
1032- labels && labels . forEach ( ( label , idx ) => {
1030+ for ( let idx = 0 ; idx < labelLength ; idx ++ ) {
10331031 let leftDisabled = 'disabled' ;
10341032 let rightDisabled = '' ;
1035- if ( idx === ( labels . length - 1 ) ) {
1033+ if ( idx === ( labelLength - 1 ) ) {
10361034 rightDisabled = 'disabled' ;
10371035 }
10381036 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 ) ;
10401038 edgeTbody . appendLine ( '<td>:</td>' ) ;
10411039 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 ) ;
10421040 edgeTbody . appendLine ( '<td>~</td>' ) ;
10431041 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 ) ;
10441042 edgeTbody . append ( '</tr>' ) ;
1045- } ) ;
1043+ }
10461044 $ ( that . wrapSelector ( '.vp-inner-popup-range-table tbody' ) ) . html ( edgeTbody . toString ( ) ) ;
10471045
10481046 // label change event
@@ -1065,7 +1063,7 @@ define([
10651063 } ) ;
10661064
10671065 } ) . catch ( function ( errObj ) {
1068- // TODO:
1066+ vpLog . display ( VP_LOG_TYPE . ERROR , errObj ) ;
10691067 } ) ;
10701068 }
10711069
@@ -1333,8 +1331,8 @@ define([
13331331 if ( type === 'column' ) {
13341332 content . appendLine ( '<tr><th><label>Add type</label></th>' ) ;
13351333 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 ' ) ;
13381336 content . appendFormatLine ( '<option value="{0}">{1}</option>' , 'condition' , 'Condition' ) ;
13391337 content . appendFormatLine ( '<option value="{0}">{1}</option>' , 'apply' , 'Apply' ) ;
13401338 content . appendLine ( '</select></td></tr>' ) ;
@@ -1344,8 +1342,8 @@ define([
13441342
13451343 content . appendLine ( '<hr style="margin: 5px 0px;"/>' ) ;
13461344
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 ' ) ;
13491347 content . appendLine ( '<table class="vp-tbl-gap5"><colgroup><col width="110px"><col width="*"><col width="15px"></colgroup>' ) ;
13501348 content . appendLine ( '<tr class="vp-inner-popup-value-row">' ) ;
13511349 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([
13681366 content . appendLine ( '</table>' ) ;
13691367 content . appendLine ( '</div>' ) ; // end of vp-inner-popup-tab value
13701368
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 ' ) ;
13731371 content . appendFormatLine ( '<div class="{0}">' , 'vp-grid-col-120' ) ;
13741372 content . appendLine ( '<label class="vp-orange-text">Target column</label>' ) ;
13751373 content . appendFormatLine ( '<select class="vp-select {0}">' , 'vp-inner-popup-value-col-list' ) ;
@@ -1718,15 +1716,15 @@ define([
17181716 content . appendLine ( '</td></tr>' ) ;
17191717 content . appendLine ( '<tr><th><label>Replace type</label></th>' ) ;
17201718 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 ' ) ;
17221720 content . appendFormatLine ( '<option value="{0}">{1}</option>' , 'condition' , 'Condition' ) ;
17231721 content . appendLine ( '</select></td></tr>' ) ;
17241722 content . appendLine ( '</table>' ) ;
17251723 content . appendLine ( '</div>' ) ; // end of vp-inner-popup-header
17261724
17271725 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 ' ) ;
17301728 content . appendFormatLine ( '<label><input type="checkbox" class="{0}"/><span>{1}</span></label>' , 'vp-inner-popup-use-regex' , 'Use Regular Expression' ) ;
17311729 content . appendLine ( '<br/><br/>' ) ;
17321730 content . appendFormatLine ( '<div class="{0}">' , 'vp-inner-popup-replace-table' ) ;
@@ -2348,13 +2346,13 @@ define([
23482346 }
23492347 var tab = $ ( this . wrapSelector ( '.vp-inner-popup-addtype' ) ) . val ( ) ;
23502348 if ( type === FRAME_EDIT_TYPE . ADD_ROW ) {
2351- tab = 'variable ' ;
2349+ tab = 'calculate ' ;
23522350 }
23532351 content [ 'addtype' ] = tab ;
2354- if ( tab == 'variable ' ) {
2352+ if ( tab == 'calculate ' ) {
23552353 let values = [ ] ;
23562354 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 ) => {
23582356 let varType = $ ( tag ) . find ( '.vp-inner-popup-vartype' ) . val ( ) ;
23592357 if ( varType === 'variable' ) {
23602358 let valueastext = $ ( tag ) . find ( '.vp-inner-popup-istext' ) . prop ( 'checked' ) ;
@@ -2371,7 +2369,7 @@ define([
23712369 } ) ;
23722370 content [ 'values' ] = values ;
23732371 content [ 'opers' ] = opers ;
2374- } else if ( tab == 'value ' ) {
2372+ } else if ( tab == 'replace ' ) {
23752373 content [ 'target' ] = $ ( this . wrapSelector ( '.vp-inner-popup-value-col-list option:selected' ) ) . data ( 'code' ) ;
23762374 var useregex = $ ( this . wrapSelector ( '.vp-inner-popup-use-regex' ) ) . prop ( 'checked' ) ;
23772375 content [ 'useregex' ] = useregex ;
@@ -2428,7 +2426,7 @@ define([
24282426 content [ 'name' ] = $ ( this . wrapSelector ( '.vp-inner-popup-input1' ) ) . data ( 'code' ) ;
24292427 var tab = $ ( this . wrapSelector ( '.vp-inner-popup-replacetype' ) ) . val ( ) ;
24302428 content [ 'replacetype' ] = tab ;
2431- if ( tab == 'value ' ) {
2429+ if ( tab == 'replace ' ) {
24322430 var useregex = $ ( this . wrapSelector ( '.vp-inner-popup-use-regex' ) ) . prop ( 'checked' ) ;
24332431 content [ 'useregex' ] = useregex ;
24342432 content [ 'list' ] = [ ] ;
@@ -2825,7 +2823,7 @@ define([
28252823 return '' ;
28262824 }
28272825 var tab = content . addtype ;
2828- if ( tab == 'variable ' ) {
2826+ if ( tab == 'calculate ' ) {
28292827 let values = [ ] ;
28302828 content [ 'values' ] && content [ 'values' ] . forEach ( ( val , idx ) => {
28312829 if ( idx > 0 ) {
@@ -2839,7 +2837,7 @@ define([
28392837 } else {
28402838 code . appendFormat ( "{0}[{1}] = {2}" , tempObj , content . name , valueStr ) ;
28412839 }
2842- } else if ( tab == 'value ' ) {
2840+ } else if ( tab == 'replace ' ) {
28432841 var replaceStr = new com_String ( ) ;
28442842 var targetName = content [ 'target' ] ;
28452843 var useRegex = content [ 'useregex' ] ;
@@ -2916,7 +2914,7 @@ define([
29162914 case FRAME_EDIT_TYPE . REPLACE :
29172915 var name = content . name ;
29182916 var tab = content . replacetype ;
2919- if ( tab === 'value ' ) {
2917+ if ( tab === 'replace ' ) {
29202918 var replaceStr = new com_String ( ) ;
29212919 var useRegex = content [ 'useregex' ] ;
29222920 content [ 'list' ] . forEach ( ( obj , idx ) => {
0 commit comments