@@ -862,6 +862,15 @@ define([
862
862
let tag = $ ( this ) . closest ( '.vp-inner-popup-sortby-item' ) ;
863
863
tag . insertAfter ( tag . next ( ) ) ;
864
864
} ) ;
865
+ } else if ( menuType === FRAME_EDIT_TYPE . DROP_NA ) {
866
+ $ ( this . wrapSelector ( '.vp-inner-popup-how' ) ) . on ( 'change' , function ( ) {
867
+ let val = $ ( this ) . val ( ) ;
868
+ if ( val === '' ) {
869
+ $ ( that . wrapSelector ( '.vp-inner-popup-thresh' ) ) . prop ( 'disabled' , false ) ;
870
+ } else {
871
+ $ ( that . wrapSelector ( '.vp-inner-popup-thresh' ) ) . prop ( 'disabled' , true ) ;
872
+ }
873
+ } ) ;
865
874
}
866
875
867
876
}
@@ -1585,7 +1594,12 @@ define([
1585
1594
content . appendFormatLine ( '<thead style="height: 30px"><th>{0}</th><th>{1}</th><th class="{2}">{3}</th></thead>'
1586
1595
, 'Column' , 'Data type' , 'vp-orange-text' , 'New data type' ) ;
1587
1596
content . appendLine ( '<tbody>' ) ;
1588
- this . state . selected . forEach ( ( col , idx ) => {
1597
+ let selectedList = this . state . selected ;
1598
+ if ( selectedList . length === 0 ) {
1599
+ // select all
1600
+ selectedList = this . state . columnList ;
1601
+ }
1602
+ selectedList . forEach ( ( col , idx ) => {
1589
1603
content . appendLine ( '<tr>' ) ;
1590
1604
content . appendFormatLine ( '<td title="{0}">{1}</td>' , col . label , col . label ) ;
1591
1605
content . appendFormatLine ( '<td><input type="text" value="{0}" readonly/></td>' , col . type ) ;
@@ -1859,25 +1873,25 @@ define([
1859
1873
pandasObject : this . state . tempObj ,
1860
1874
selectedColumns : [ com_util . convertToStr ( contentState . name , contentState . nameastext ) ] ,
1861
1875
config : { name : 'Subset' } } ,
1862
- {
1863
- useInputVariable : true ,
1864
- useInputColumns : true ,
1865
- targetSelector : this . wrapSelector ( '.vp-inner-popup-subset' ) ,
1866
- pageThis : this ,
1867
- allowSubsetTypes : [ 'iloc' , 'loc' ] ,
1868
- beforeOpen : function ( subsetThis ) {
1869
- let contentState = that . getPopupContent ( type ) ;
1870
- let name = com_util . convertToStr ( contentState . name , contentState . nameastext ) ;
1871
- subsetThis . state . selectedColumns = [ name ] ;
1872
- } ,
1873
- finish : function ( code ) {
1874
- that . subsetCm . setValue ( code ) ;
1875
- that . subsetCm . save ( ) ;
1876
- setTimeout ( function ( ) {
1877
- that . subsetCm . refresh ( ) ;
1878
- } , 1 ) ;
1879
- }
1880
- } ) ;
1876
+ {
1877
+ useInputVariable : true ,
1878
+ useInputColumns : true ,
1879
+ targetSelector : this . wrapSelector ( '.vp-inner-popup-subset' ) ,
1880
+ pageThis : this ,
1881
+ allowSubsetTypes : [ 'iloc' , 'loc' ] ,
1882
+ beforeOpen : function ( subsetThis ) {
1883
+ let contentState = that . getPopupContent ( type ) ;
1884
+ let name = com_util . convertToStr ( contentState . name , contentState . nameastext ) ;
1885
+ subsetThis . state . selectedColumns = [ name ] ;
1886
+ } ,
1887
+ finish : function ( code ) {
1888
+ that . subsetCm . setValue ( code ) ;
1889
+ that . subsetCm . save ( ) ;
1890
+ setTimeout ( function ( ) {
1891
+ that . subsetCm . refresh ( ) ;
1892
+ } , 1 ) ;
1893
+ }
1894
+ } ) ;
1881
1895
// initial code
1882
1896
var code = this . subsetEditor . generateCode ( ) ;
1883
1897
this . subsetCm . setValue ( code ) ;
@@ -2086,12 +2100,19 @@ define([
2086
2100
content [ 'ascending' ] = $ ( this . wrapSelector ( '.vp-inner-popup-isascending' ) ) . val ( ) ;
2087
2101
break ;
2088
2102
case FRAME_EDIT_TYPE . AS_TYPE :
2089
- this . state . selected . forEach ( ( col , idx ) => {
2103
+ let selectedList = this . state . selected ;
2104
+ if ( selectedList . length === 0 ) {
2105
+ // select all
2106
+ selectedList = this . state . columnList ;
2107
+ }
2108
+ selectedList . forEach ( ( col , idx ) => {
2090
2109
var value = $ ( this . wrapSelector ( '.vp-inner-popup-astype' + idx ) ) . val ( ) ;
2091
- content [ idx ] = {
2092
- label : col . code ,
2093
- value : value
2094
- } ;
2110
+ if ( value !== undefined && value !== '' ) {
2111
+ content [ idx ] = {
2112
+ label : col . code ,
2113
+ value : value
2114
+ } ;
2115
+ }
2095
2116
} ) ;
2096
2117
break ;
2097
2118
case FRAME_EDIT_TYPE . DISCRETIZE :
@@ -2294,22 +2315,26 @@ define([
2294
2315
}
2295
2316
break ;
2296
2317
case FRAME_EDIT_TYPE . DROP_NA :
2297
- var locObj = '' ;
2318
+ var dropNAOptions = [ ] ;
2298
2319
if ( axis == FRAME_AXIS . ROW ) {
2299
- code . appendFormat ( "{0}.loc[[{1}],:].dropna( axis=0" , tempObj , selectedName ) ;
2320
+ dropNAOptions . push ( " axis=1" ) ;
2300
2321
} else {
2301
- code . appendFormat ( "{0}.loc[:,[{1}]].dropna(axis=1" , tempObj , selectedName ) ;
2322
+ dropNAOptions . push ( "axis=0" ) ;
2323
+ }
2324
+ if ( selectedName && selectedName !== '' ) {
2325
+ dropNAOptions . push ( com_util . formatString ( "subset=[{0}]" , selectedName ) ) ;
2302
2326
}
2303
2327
if ( content . how && content . how !== '' ) {
2304
- code . appendFormat ( ", how='{0}'", content . how ) ;
2328
+ dropNAOptions . push ( com_util . formatString ( " how='{0}'", content . how ) ) ;
2305
2329
}
2306
2330
if ( content . thresh && content . thresh !== '' ) {
2307
- code . appendFormat ( ", thresh={0}", content . thresh ) ;
2331
+ dropNAOptions . push ( com_util . formatString ( " thresh={0}", content . thresh ) ) ;
2308
2332
}
2309
2333
if ( content . ignore_index && content . ignore_index !== '' ) {
2310
- code . appendFormat ( ", ignore_index={0}", content . ignore_index ) ;
2334
+ dropNAOptions . push ( com_util . formatString ( " ignore_index={0}", content . ignore_index ) ) ;
2311
2335
}
2312
- code . append ( ", inplace=True)" ) ;
2336
+ dropNAOptions . push ( "inplace=True" ) ;
2337
+ code . appendFormat ( "{0}.dropna({1})" , tempObj , dropNAOptions . join ( ', ' ) ) ;
2313
2338
break ;
2314
2339
case FRAME_EDIT_TYPE . DROP_DUP :
2315
2340
let dropDupOptions = [ ] ;
@@ -2322,7 +2347,7 @@ define([
2322
2347
if ( content . ignore_index && content . ignore_index !== '' ) {
2323
2348
dropDupOptions . push ( com_util . formatString ( "ignore_index={0}" , content . ignore_index ) ) ;
2324
2349
}
2325
- dropDupOptions . push ( com_util . formatString ( "inplace=True" ) ) ;
2350
+ dropDupOptions . push ( "inplace=True" ) ;
2326
2351
code . appendFormat ( "{0}.drop_duplicates({1})" , tempObj , dropDupOptions . join ( ', ' ) ) ;
2327
2352
break ;
2328
2353
case FRAME_EDIT_TYPE . DROP_OUT :
0 commit comments