@@ -136,31 +136,39 @@ export const indexLoc = (ndframe, kwargs) => {
136136 throw new Error ( `Specified row index ${ row_val } is bigger than maximum row index of ${ max_rowIndex } ` ) ;
137137 }
138138
139- let value = data_values [ row_val ]
140- let row_data = [ ]
139+ if ( Array . isArray ( data_values [ 0 ] ) ) {
141140
142- for ( var i in columns ) {
143- var col_index ;
144- if ( kwargs [ "type" ] == "loc" && ! isColumnSplit ) {
145- col_index = ndframe . columns . indexOf ( columns [ i ] ) ; //obtain the column index
141+ let value = data_values [ row_val ]
142+ let row_data = [ ]
146143
147- if ( col_index == - 1 ) {
148- throw new Error ( `Column ${ columns [ i ] } does not exist` ) ;
149- }
150- } else {
151- col_index = columns [ i ] ;
152- let max_colIndex = ndframe . columns . length - 1 ; //assign the maximum column index to a value
153144
154- if ( col_index > max_colIndex ) {
155- throw new Error ( `column index ${ col_index } is bigger than ${ max_colIndex } ` ) ;
145+ for ( var i in columns ) {
146+ var col_index ;
147+ if ( kwargs [ "type" ] == "loc" && ! isColumnSplit ) {
148+ col_index = ndframe . columns . indexOf ( columns [ i ] ) ; //obtain the column index
149+
150+ if ( col_index == - 1 ) {
151+ throw new Error ( `Column ${ columns [ i ] } does not exist` ) ;
152+ }
153+ } else {
154+ col_index = columns [ i ] ;
155+ let max_colIndex = ndframe . columns . length - 1 ; //assign the maximum column index to a value
156+
157+ if ( col_index > max_colIndex ) {
158+ throw new Error ( `column index ${ col_index } is bigger than ${ max_colIndex } ` ) ;
159+ }
156160 }
161+
162+ let elem = value [ col_index ] ; //obtain the element at the column index
163+ row_data . push ( elem ) ;
157164 }
158165
159- let elem = value [ col_index ] ; //obtain the element at the column index
160- row_data . push ( elem ) ;
161- }
166+ new_data . push ( row_data ) ; //store the data for each row in the new_data
162167
163- new_data . push ( row_data ) ; //store the data for each row in the new_data
168+ } else {
169+
170+ new_data . push ( data_values [ row_val ] )
171+ }
164172
165173 }
166174
0 commit comments