@@ -92,6 +92,7 @@ define([
9292 useCopy : false ,
9393 toFrame : false ,
9494 subsetType : 'loc' , // subset / loc / iloc / query
95+ returnType : '' ,
9596
9697 rowType : 'condition' ,
9798 rowList : [ ] ,
@@ -197,7 +198,7 @@ define([
197198 buttonTag . appendFormat ( '<button type="button" class="{0} {1} {2}">{3}</button>' ,
198199 VP_DS_BTN , this . uuid , 'vp-button' , 'Subset' ) ;
199200 if ( this . pageThis ) {
200- $ ( this . targetSelector ) . parent ( ) . append ( buttonTag . toString ( ) ) ;
201+ $ ( buttonTag . toString ( ) ) . insertAfter ( $ ( this . targetSelector ) ) ;
201202 }
202203 }
203204 renderSubsetType ( dataType ) {
@@ -585,6 +586,7 @@ define([
585586 renderColumnConditionList ( colList ) {
586587 var tag = new com_String ( ) ;
587588 tag . appendFormatLine ( '<table class="{0}">' , VP_DS_CONDITION_TBL ) ;
589+ tag . appendLine ( this . templateForConditionBox ( colList ) ) ;
588590 tag . appendLine ( '<tr>' ) ;
589591 tag . appendFormatLine ( '<td colspan="4"><button type="button" class="{0} {1}">{2}</button></td>' ,
590592 VP_DS_BUTTON_ADD_CONDITION , 'vp-add-col' , '+ Condition' ) ;
@@ -765,6 +767,7 @@ define([
765767 var varType = JSON . parse ( result ) ;
766768 that . state . pandasObject = prevValue ;
767769 that . state . dataType = varType ;
770+ that . state . returnType = varType ;
768771 $ ( that . wrapSelector ( '.' + VP_DS_PANDAS_OBJECT_BOX ) ) . replaceWith ( function ( ) {
769772 return $ ( com_util . formatString ( '<div style="display:inline-block"><input class="{0} {1}" value="{2}" disabled /></div>' ,
770773 'vp-input' , VP_DS_PANDAS_OBJECT , prevValue ) ) ;
@@ -805,6 +808,7 @@ define([
805808 $ ( this . wrapSelector ( ) ) . data ( 'dtype' , item . dtype ) ;
806809 that . state . pandasObject = value ;
807810 that . state . dataType = item . dtype ;
811+ that . state . returnType = item . dtype ;
808812 $ ( this . wrapSelector ( ) ) . trigger ( 'change' ) ;
809813 } ) ;
810814 variableInput . setNormalFilter ( true ) ;
@@ -1183,6 +1187,7 @@ define([
11831187
11841188 that . state . pandasObject = varName ;
11851189 that . state . dataType = event . dataType ? event . dataType : that . state . dataType ;
1190+ that . state . returnType = that . state . dataType ;
11861191 that . state . rowList = [ ] ;
11871192 that . state . rowLimit = 10 ;
11881193 that . state . columnList = [ ] ;
@@ -1835,10 +1840,14 @@ define([
18351840 if ( this . state . colType == 'indexing' ) {
18361841 if ( this . useInputColumns == true ) {
18371842 colList = this . state . selectedColumns ;
1838- if ( colList . length == 1 ) {
1839- colSelection . appendFormat ( '{0}' , colList . toString ( ) ) ;
1840- } else {
1841- colSelection . appendFormat ( '[{0}]' , colList . toString ( ) ) ;
1843+ if ( colList . length > 0 ) {
1844+ if ( colList . length == 1 ) {
1845+ colSelection . appendFormat ( '{0}' , colList . toString ( ) ) ;
1846+ this . state . returnType = 'Series' ;
1847+ } else {
1848+ colSelection . appendFormat ( '[{0}]' , colList . toString ( ) ) ;
1849+ this . state . returnType = 'DataFrame' ;
1850+ }
18421851 }
18431852 } else {
18441853 var colTags = $ ( this . wrapSelector ( '.' + VP_DS_SELECT_ITEM + '.select-col.added:not(.moving)' ) ) ;
@@ -1858,11 +1867,14 @@ define([
18581867 // to frame
18591868 if ( this . state . toFrame ) {
18601869 colSelection . appendFormat ( '[{0}]' , colList . toString ( ) ) ;
1870+ this . state . returnType = 'DataFrame' ;
18611871 } else {
18621872 colSelection . appendFormat ( '{0}' , colList . toString ( ) ) ;
1873+ this . state . returnType = 'Series' ;
18631874 }
18641875 } else {
18651876 colSelection . appendFormat ( '[{0}]' , colList . toString ( ) ) ;
1877+ this . state . returnType = 'DataFrame' ;
18661878 }
18671879
18681880 } else {
@@ -1877,31 +1889,34 @@ define([
18771889 }
18781890
18791891 // use simple selection
1880- if ( this . state . subsetType == 'subset' ) {
1881- if ( rowSelection . toString ( ) != ':' && rowSelection . toString ( ) != '' ) {
1882- code . appendFormat ( '[{0}]' , rowSelection . toString ( ) ) ;
1883- }
1884- if ( colSelection . toString ( ) != ':' && colSelection . toString ( ) != '' ) {
1885- code . appendFormat ( '[{0}]' , colSelection . toString ( ) ) ;
1886- }
1887- } else if ( this . state . subsetType == 'loc' ) {
1888- if ( this . state . dataType == 'DataFrame' ) {
1889- code . appendFormat ( '.loc[{0}, {1}]' , rowSelection . toString ( ) , colSelection . toString ( ) ) ;
1890- } else {
1891- code . appendFormat ( '.loc[{0}]' , rowSelection . toString ( ) ) ;
1892- }
1893- } else if ( this . state . subsetType == 'iloc' ) {
1894- if ( this . state . dataType == 'DataFrame' ) {
1895- code . appendFormat ( '.iloc[{0}, {1}]' , rowSelection . toString ( ) , colSelection . toString ( ) ) ;
1896- } else {
1897- code . appendFormat ( '.iloc[{0}]' , rowSelection . toString ( ) ) ;
1898- }
1899- } else if ( this . state . subsetType == 'query' ) {
1900- if ( rowSelection . toString ( ) != ':' && rowSelection . toString ( ) != '' ) {
1901- code . appendFormat ( '.query("{0}")' , rowSelection . toString ( ) ) ;
1902- }
1903- if ( colSelection . toString ( ) != ':' && colSelection . toString ( ) != '' ) {
1904- code . appendFormat ( '[{0}]' , colSelection . toString ( ) ) ;
1892+ if ( ( rowSelection . toString ( ) !== ':' && rowSelection . toString ( ) !== '' )
1893+ || ( colSelection . toString ( ) !== ':' && colSelection . toString ( ) !== '' ) ) {
1894+ if ( this . state . subsetType == 'subset' ) {
1895+ if ( rowSelection . toString ( ) != ':' && rowSelection . toString ( ) != '' ) {
1896+ code . appendFormat ( '[{0}]' , rowSelection . toString ( ) ) ;
1897+ }
1898+ if ( colSelection . toString ( ) != ':' && colSelection . toString ( ) != '' ) {
1899+ code . appendFormat ( '[{0}]' , colSelection . toString ( ) ) ;
1900+ }
1901+ } else if ( this . state . subsetType == 'loc' ) {
1902+ if ( this . state . dataType == 'DataFrame' ) {
1903+ code . appendFormat ( '.loc[{0}, {1}]' , rowSelection . toString ( ) , colSelection . toString ( ) ) ;
1904+ } else {
1905+ code . appendFormat ( '.loc[{0}]' , rowSelection . toString ( ) ) ;
1906+ }
1907+ } else if ( this . state . subsetType == 'iloc' ) {
1908+ if ( this . state . dataType == 'DataFrame' ) {
1909+ code . appendFormat ( '.iloc[{0}, {1}]' , rowSelection . toString ( ) , colSelection . toString ( ) ) ;
1910+ } else {
1911+ code . appendFormat ( '.iloc[{0}]' , rowSelection . toString ( ) ) ;
1912+ }
1913+ } else if ( this . state . subsetType == 'query' ) {
1914+ if ( rowSelection . toString ( ) != ':' && rowSelection . toString ( ) != '' ) {
1915+ code . appendFormat ( '.query("{0}")' , rowSelection . toString ( ) ) ;
1916+ }
1917+ if ( colSelection . toString ( ) != ':' && colSelection . toString ( ) != '' ) {
1918+ code . appendFormat ( '[{0}]' , colSelection . toString ( ) ) ;
1919+ }
19051920 }
19061921 }
19071922
0 commit comments