I run into problem when i run my model with some parameters. So i want to do some data cleaning before run the model. Is there a quick way to delete columns with same values? Please advise how to do it with JSL or any other way that may fit?
I'm not sure if I get you Right,
for modelling you can select the columns that you think are important, so there is no Need to delete the column.
You want to delete some rows where a column has the same value?
Below is the Code for it:
Otherwise please describe more in Detail what you Need, an example May be very helpful.
Names Default To Here( 1 ); dt = Open( "$SAMPLE_DATA/Big Class.jmp" ); wait(3); dt << Select duplicate rows( Match( :age ) ); dt << delete rows;
This one deletes columns:
Names Default To Here( 1 ); dt = Open( "$SAMPLE_DATA/Big Class.jmp" ); // make some copies of columns dt << New Column( "weight_copy", set each value( :weight ) ); dt << New Column( "height_copy", set each value( :height ) ); to_delete_lst = {}; For( i = 1, i < N Col( dt ), i++, For( j = i + 1, j <= N Col( dt ), j++, If( (Column( i ) << get data type) == (Column( j ) << get data type), // all celles are equal ? If( Mean( (Column( i ) << get values) == (Column( j ) << get values) ) == 1, Print( (Column( i ) << get name) || " equal to " || (Column( j ) << get name) ); insert into(to_delete_lst, j); ); ); ) ); // show list of equals Show(to_delete_lst); wait(3); dt << select columns(to_delete_lst); dt << delete columns;
When I run this code, it correctly identifies the duplicate cols but doesn't actually delete them. The log shows no errors.
"height equal to height_copy""weight equal to weight_copy"to_delete_lst = {7, 6};Scriptable[]
I am running v13.2.1