cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
nthai
Level III

Replace multiple rows value from one column is not working properly

Hi JMP community,

 

I have occured one issue that quite weird. Here's my code:

dt_temp = data table("aaaa");

dt_temp << Summary( Group( :Column1,:Column2), Freq( "None" ), Weight( "None" ),output table name( "summary" ) );
data table("summary") << select where (:N rows >= 2 & !contains(:Column1,"AA") & !contains(:Column1,"BB") );
rows = dt_temp << get selected rows; 

dt_temp:Column3[rows] = "";
//Column(dt_temp, "Column3")[rows] = "";

When i run this code, even the rows has value like [10, 11, 20, 21] but the end result from column3 is different. It replace others row (let's say row 1, 5, ...) instead of rows in get selected rows. 

Could you help me to resolve this issue?

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Replace multiple rows value from one column is not working properly

Based on this Data table subscripting the way I'm setting the cell values might have become available in JMP13.

 

I'll try to avoid looping but I don't have access to older version of JMP than 15, so I'm not sure if this will work either:

 

Names Default To Here(1);
dt_temp = Open("$SAMPLE_DATA/Big Class.jmp");
dt_summary = dt_temp << Summary(Group(:age, :sex), Freq("None"), Weight("None"), output table name( "summary" ));
dt_summary << Select Where(:N Rows >= 3 & !Contains(:sex, "M"));
//get rows which should be set to empty rows = dt_temp << Get Selected Rows; //get all values in name column colValues = dt_temp:name << get values; show(colValues); //set selected rows in the colValues list to "" colValues[rows] = ""; show(colValues); dt_temp:name << Set Values(colValues);

 

 

 

-Jarmo

View solution in original post

txnelson
Super User

Re: Replace multiple rows value from one column is not working properly

Try closing the summary table before setting the values in the original table.  The Summary table is linked to the original and is keeping it from being updated.

dt_temp = data table("aaaa");

dt_summ = dt_temp << Summary( Group( :Column1,:Column2), Freq( "None" ), Weight( "None" ),output table name( "summary" ) );
data table("summary") << select where (:N rows >= 2 & !contains(:Column1,"AA") & !contains(:Column1,"BB") );
rows = dt_temp << get selected rows; 
close( dt_summ, nosave );


dt_temp:Column3[rows] = "";
//Column(dt_temp, "Column3")[rows] = "";
Jim

View solution in original post

7 REPLIES 7
jthi
Super User

Re: Replace multiple rows value from one column is not working properly

Are you trying to replace values in the original data table or in the summary table? This seems to work just fine for me:

Names Default To Here(1);
dt_temp = Open("$SAMPLE_DATA/Big Class.jmp");
dt_temp << Summary(Group(:age, :sex), Freq("None"), Weight("None"), output table name( "summary" ));

data table("summary") << Select Where(:N Rows >= 3 & !Contains(:sex, "M"));
rows = dt_temp << Get Selected Rows;
show(dt_temp:name[rows]);
dt_temp:name[rows] = "";
show(dt_temp:name[rows]);
-Jarmo
nthai
Level III

Re: Replace multiple rows value from one column is not working properly

Hi Jarmo,

 

Thank you for your suggestion but it seems doesn't work for me.

 

To clarify, i would like to replace values in original table based on the conditional of summary table.

 

I have tried to run your code as well, and here's the result:

 

Selected rows from summary table:

 

nthai_0-1622904024925.png

 

Selected rows from main table. There was 15 rows were selected but it replaced only 1st rows of each group:

 

nthai_1-1622904069981.png

 

jthi
Super User

Re: Replace multiple rows value from one column is not working properly

Which version of JMP are you using? I'm using 15.2.1 and my example seems to work just fine for me:

jthi_0-1622905425290.png

 

-Jarmo
nthai
Level III

Re: Replace multiple rows value from one column is not working properly

i'm using Jmp Pro 12.2.0, 64 bit version. Log file for your reference:

 

nthai_2-1622909514433.png

 

Although log file showing row number (-1) is not invalid but when i shows rows, there's no such row like that.

 

 

jthi
Super User

Re: Replace multiple rows value from one column is not working properly

Based on this Data table subscripting the way I'm setting the cell values might have become available in JMP13.

 

I'll try to avoid looping but I don't have access to older version of JMP than 15, so I'm not sure if this will work either:

 

Names Default To Here(1);
dt_temp = Open("$SAMPLE_DATA/Big Class.jmp");
dt_summary = dt_temp << Summary(Group(:age, :sex), Freq("None"), Weight("None"), output table name( "summary" ));
dt_summary << Select Where(:N Rows >= 3 & !Contains(:sex, "M"));
//get rows which should be set to empty rows = dt_temp << Get Selected Rows; //get all values in name column colValues = dt_temp:name << get values; show(colValues); //set selected rows in the colValues list to "" colValues[rows] = ""; show(colValues); dt_temp:name << Set Values(colValues);

 

 

 

-Jarmo
txnelson
Super User

Re: Replace multiple rows value from one column is not working properly

Try closing the summary table before setting the values in the original table.  The Summary table is linked to the original and is keeping it from being updated.

dt_temp = data table("aaaa");

dt_summ = dt_temp << Summary( Group( :Column1,:Column2), Freq( "None" ), Weight( "None" ),output table name( "summary" ) );
data table("summary") << select where (:N rows >= 2 & !contains(:Column1,"AA") & !contains(:Column1,"BB") );
rows = dt_temp << get selected rows; 
close( dt_summ, nosave );


dt_temp:Column3[rows] = "";
//Column(dt_temp, "Column3")[rows] = "";
Jim
nthai
Level III

Re: Replace multiple rows value from one column is not working properly

Thank you Jim and Jarmo! Both solutions works like a charm for me!