@@ -79,36 +79,37 @@ export class DataFrame extends Ndframe {
7979 throw Error ( "No column found. Axis of 1 must be accompanied by an array of column(s) names" )
8080 }
8181 let self = this ;
82+ let new_col_data = { }
83+ let new_dtype = [ ]
84+
8285 const index = data . map ( ( x ) => {
8386 let col_idx = self . columns . indexOf ( x )
8487 if ( col_idx == - 1 ) {
8588 throw new Error ( `column "${ x } " does not exist` )
8689 }
8790 return col_idx
8891 } ) ;
89- const values = this . values
90- let new_dtype = [ ]
91- let new_data = values . map ( function ( element ) {
92- let new_arr = utils . __remove_arr ( element , index ) ;
93- new_dtype = utils . __remove_arr ( self . dtypes , index ) ;
94- return new_arr ;
95- } ) ;
92+
93+ this . col_data . forEach ( ( col , idx ) => {
94+ if ( ! index . includes ( idx ) ) {
95+ new_col_data [ self . column_names [ idx ] ] = col
96+ new_dtype . push ( self . dtypes [ idx ] )
97+ }
98+ } )
9699
97100 if ( ! kwargs [ 'inplace' ] ) {
98- let old_cols = this . columns
99- let columns = utils . __remove_arr ( this . columns , index ) ;
100- let df = new DataFrame ( new_data , { columns : columns , index : self . index , dtypes : new_dtype } )
101- df . __set_col_property ( df , df . col_data , columns , old_cols )
101+ let old_cols = self . columns
102+ let new_columns = Object . keys ( new_col_data )
103+ let df = new DataFrame ( new_col_data , { index : self . index , dtypes : new_dtype } )
104+ df . __set_col_property ( df , df . col_data , new_columns , old_cols )
102105 return df
103106
104107 } else {
105- let new_cols = utils . __remove_arr ( this . columns , index ) ;
106- let old_cols = this . columns
107- this . columns = new_cols
108- this . row_data_tensor = tf . tensor ( new_data ) ;
109- this . data = new_data
110- this . __set_col_types ( new_dtype , false )
111- this . __set_col_property ( this , this . col_data , new_cols , old_cols )
108+ let old_cols = self . columns
109+ let new_columns = Object . keys ( new_col_data )
110+ this . __update_frame_in_place ( null , null , new_col_data , null , new_dtype )
111+ this . __set_col_property ( self , self . col_data , new_columns , old_cols )
112+
112113 }
113114
114115 } else {
0 commit comments