@@ -423,6 +423,68 @@ describe("DataFrame", function () {
423423
424424 } ) ;
425425
426+ it ( "column slice starting with 0 and returning a single result works" , function ( ) {
427+ let data = {
428+ "Name" : [ "Apples" , "Mango" , "Banana" , "Pear" ] ,
429+ "Count" : [ 21 , 5 , 30 , 10 ] ,
430+ "Price" : [ 200 , 300 , 40 , 250 ]
431+ } ;
432+ let df = new dfd . DataFrame ( data ) ;
433+ let sub_df = df . iloc ( { rows : [ "2:3" ] , columns : [ "0:1" ] } ) ;
434+ const result = [ [ "Banana" ] ] ;
435+ assert . deepEqual ( sub_df . values , result ) ;
436+
437+ } ) ;
438+ it ( "column slice with format '0:' works" , function ( ) {
439+ let data = {
440+ "Name" : [ "Apples" , "Mango" , "Banana" , "Pear" ] ,
441+ "Count" : [ 21 , 5 , 30 , 10 ] ,
442+ "Price" : [ 200 , 300 , 40 , 250 ]
443+ } ;
444+ let df = new dfd . DataFrame ( data ) ;
445+ let sub_df = df . iloc ( { rows : [ "2:3" ] , columns : [ "0:" ] } ) ;
446+ const result = [ [ "Banana" , 30 , 40 ] ] ;
447+ assert . deepEqual ( sub_df . values , result ) ;
448+
449+ } ) ;
450+ it ( "column slice with format ':2' works" , function ( ) {
451+ let data = {
452+ "Name" : [ "Apples" , "Mango" , "Banana" , "Pear" ] ,
453+ "Count" : [ 21 , 5 , 30 , 10 ] ,
454+ "Price" : [ 200 , 300 , 40 , 250 ]
455+ } ;
456+ let df = new dfd . DataFrame ( data ) ;
457+ let sub_df = df . iloc ( { rows : [ "2:3" ] , columns : [ ":2" ] } ) ;
458+ const result = [ [ "Banana" , 30 ] ] ;
459+ assert . deepEqual ( sub_df . values , result ) ;
460+
461+ } ) ;
462+ it ( "row slice with format ':2' works" , function ( ) {
463+ let data = {
464+ "Name" : [ "Apples" , "Mango" , "Banana" , "Pear" ] ,
465+ "Count" : [ 21 , 5 , 30 , 10 ] ,
466+ "Price" : [ 200 , 300 , 40 , 250 ]
467+ } ;
468+ let df = new dfd . DataFrame ( data ) ;
469+ let sub_df = df . iloc ( { rows : [ ":2" ] , columns : [ ":1" ] } ) ;
470+ const result = [ [ 'Apples' ] , [ 'Mango' ] ] ;
471+ assert . deepEqual ( sub_df . values , result ) ;
472+
473+ } ) ;
474+ it ( "row slice with format '1:' works" , function ( ) {
475+ let data = {
476+ "Name" : [ "Apples" , "Mango" , "Banana" , "Pear" ] ,
477+ "Count" : [ 21 , 5 , 30 , 10 ] ,
478+ "Price" : [ 200 , 300 , 40 , 250 ]
479+ } ;
480+ let df = new dfd . DataFrame ( data ) ;
481+ let sub_df = df . iloc ( { rows : [ ":2" ] , columns : [ ":2" ] } ) ;
482+ const result = [ [ 'Apples' , 21 ] , [ 'Mango' , 5 ] ] ;
483+ assert . deepEqual ( sub_df . values , result ) ;
484+
485+ } ) ;
486+
487+
426488 } ) ;
427489
428490
0 commit comments