@@ -72,7 +72,10 @@ export default class NDframe implements NDframeInterface {
7272 }
7373
7474 if ( data === undefined || ( Array . isArray ( data ) && data . length === 0 ) ) {
75- this . loadArrayIntoNdframe ( { data : [ ] , index : [ ] , columns : [ ] , dtypes : [ ] } ) ;
75+ if ( columns === undefined ) columns = [ ] ;
76+ if ( dtypes === undefined ) dtypes = [ ] ;
77+ if ( columns . length === 0 && dtypes . length !== 0 ) ErrorThrower . throwDtypeWithoutColumnError ( ) ;
78+ this . loadArrayIntoNdframe ( { data : [ ] , index : [ ] , columns : columns , dtypes : dtypes } ) ;
7679 } else if ( utils . is1DArray ( data ) ) {
7780 this . loadArrayIntoNdframe ( { data, index, columns, dtypes } ) ;
7881 } else {
@@ -306,6 +309,7 @@ export default class NDframe implements NDframeInterface {
306309 */
307310 $setColumnNames ( columns ?: string [ ] ) {
308311
312+ // console.log(columns);
309313 if ( this . $isSeries ) {
310314 if ( columns ) {
311315 if ( this . $data . length != 0 && columns . length != 1 && typeof columns != 'string' ) {
@@ -322,7 +326,7 @@ export default class NDframe implements NDframeInterface {
322326
323327 ErrorThrower . throwColumnNamesLengthError ( this , columns )
324328 }
325- if ( Array . from ( new Set ( columns ) ) . length !== this . shape [ 1 ] ) {
329+ if ( Array . from ( new Set ( columns ) ) . length !== columns . length ) {
326330 ErrorThrower . throwColumnDuplicateError ( )
327331 }
328332
@@ -337,7 +341,10 @@ export default class NDframe implements NDframeInterface {
337341 * Returns the shape of the NDFrame. Shape is determined by [row length, column length]
338342 */
339343 get shape ( ) : Array < number > {
340- if ( this . $data . length === 0 ) return [ 0 , 0 ]
344+ if ( this . $data . length === 0 ) {
345+ if ( this . $columns . length === 0 ) return [ 0 , 0 ] ;
346+ else return [ 0 , this . $columns . length ] ;
347+ }
341348 if ( this . $isSeries ) {
342349 return [ this . $data . length , 1 ] ;
343350 } else {
0 commit comments