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
PioJesudoss
Level II

In a data frame Filter column based on another column that contains the column name

Hello Folks,

I have attached a data set. In the data set, I have column called Parameter that contains the name of the columns that are in the data set. I want to first filter the column that corresponds to each unique column name that is present in the Parameter column and then join it to the subset column that I have created and create a variability chart. At this moment I have 2 unique parameters in the Parameter column and this can vary week on week, so I would like it to be parameterized.  I have below some of the code that I have done. Any help would be appreciated

Thanks

Pio 

 

dt_2 = Data Table( "jmp_question_T_V0" ) << Summary(
Group( :Parameter ),
Freq( "None" ),
Weight( "None" )
);
 
lst = column(dt_2,1) << GetAsMatrix();
close(dt_2,no save);
 
subset_cols = {:Name("PRA"), :Name("WA"), :Name("CH"), :Name("WA_D"),
:Name("CH_D"),:Name("SL_T"),:Name("TST_DATE"),:Name("IL_M"),:Name("QTY"),
:Name("W"),:Name("Parameter"),:Name("h_t_d")};
 
length (lst)
 
iparam = 1
while(iparam=length(lst)) {
print(lst[iparam])
dt=dt_1
 
dt_1 << select where (:Parameter == lst[iparam])  //works
dt<<subset(output table) //works
dt<< subset(all rows, columns(subset_cols))
 
dt_param<<Subset((dt_1 << select where (:Parameter == lst[iparam])), columns(subset_cols))

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: In a data frame Filter column based on another column that contains the column name

Something like this?

Names Default To Here(1);

dt = Current Data Table();

params = Associative Array(Column(dt, "Parameter")) << get keys;

dts = {};

For Each({param}, params,
	cols_to_subset = {"Parameter"};
	Insert Into(cols_to_subset, param);
	cur_rows = dt << get rows where(:Parameter == param);
	dt_subset = dt << Subset(Rows(cur_rows), Selected Rows(0), Columns(cols_to_subset), Output Table("Parameter="||param));
	Insert Into(dts, dt_subset);
);

jthi_0-1736850380881.png

 

 

-Jarmo

View solution in original post

PioJesudoss
Level II

Re: In a data frame Filter column based on another column that contains the column name

Thanks Jarmo.

 

I just starting jmp scripting and I need variablity chart as past of the for loop for each data table to save the image 

dts={};

For Each({param}, params,
	//cols_to_subset = {"Parameter"};
	cols_to_subset = {:Name("PRODUCT"), :Name("WAFER_LOT"), :Name("CHUNK"), :Name("WAFER_ID"),
	:Name("CHUNK_ID"),:Name("SLIDER_LOT"),:Name("TST_DATE"),:Name("WAFER_LOT"),:Name("FAIL_MODES"),:Name("DISPOSITION"),:Name("QTY_HGA"),
:Name("min_ET_date"),:Name("wafer_type"),:Name("wd_wafer_mfr_loc"),:Name("cq_or_child"),:Name("radius"),:Name("calc_sh_rd1"),
:Name("calc_sh_rd2"),:Name("CTQ_WRT_WDTH"),:Name("Parameter"),:Name("Product_waferID_Chunk_ID"),:Name("hga_tester_id")};
	Insert Into(cols_to_subset, param);
	//Insert Into(param,cols_to_subset);
	cur_rows = dt_tester << get rows where(:Parameter == param);
	dt_subset = dt_tester << Subset(Rows(cur_rows), Selected Rows(0), Columns(cols_to_subset) ,Output Table("Parameter="||param));
	//Insert Into(dts, dt_subset);
	//);
	
	
	//this part not working
	dt_subset << Variability Chart(
	Y(__params__),
	X( :WAFER_LOT, :CHUNK, :hga_tester_id ),
	Sigma Multiplier( 6 ),
	Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),
	Variability Analysis( Std Dev Chart( 0 ) ),
	SendToReport(
		Dispatch(
			{__Variability Chart__},
			"Variability Chart",
			FrameBox,
			{Row Legend(
				hga_tester_id,
				Color( 1 ),
				Color Theme( "JMP Default"(1) ),
				Marker( 0 ),
				Marker Theme( "" ),
				Continuous Scale( 0 ),
				Reverse Scale( 0 ),
				Excluded Rows( 0 )
			)}
		)
	)
)
);

View solution in original post

6 REPLIES 6
jthi
Super User

Re: In a data frame Filter column based on another column that contains the column name

The script you have provided doesn't work as it is missing ; and using incorrect syntax for while loop. If you want to get unique values from a character column, you can use Summary table, Summarize function or Associative Array. I'm not exactly sure what you wish to do as you only provided single .csv file.

Names Default To Here(1);

dt = Current Data Table();

params = Associative Array(Column(dt, "Parameter")) << get keys;

If you wish to create separate subsets based on the Parameter column, you can just use that as a subset by column

jthi_0-1736522129795.png

Names Default To Here(1);

dt = Current Data Table();

mycols = {"W", "W_s", "R_rd1", "R_rd1_s"};

dt_subsets = dt << Subset(By(:Parameter), Selected Rows(0), Columns(mycols));

Or looping

Names Default To Here(1);

dt = Current Data Table();

params = Associative Array(Column(dt, "Parameter")) << get keys;
mycols = {"W", "W_s", "R_rd1", "R_rd1_s"};

dts = {};

For Each({param}, params,
	cur_rows = dt << get rows where(:Parameter == param);
	dt_subset = dt << Subset(Rows(cur_rows), Selected Rows(0), Columns(mycols));
	Insert Into(dts, dt_subset);
);

You could also select the rows but it is usually unnecessary

-Jarmo
PioJesudoss
Level II

Re: In a data frame Filter column based on another column that contains the column name

Hi Jthi,

Thanks for your reply but what I want is this. I mean, If Parameter has S_rd2_iqr, then I want only the column S_rd2_iqr to be filtered as shown in the screen shot. If Parameter has S_rd2, then I want only the column S_rd2 to be filtered as shown in the screen shot. These parameters will vary each time so I want them to be parameterized

 

PioJesudoss_0-1736848916373.png

 

jthi
Super User

Re: In a data frame Filter column based on another column that contains the column name

Something like this?

Names Default To Here(1);

dt = Current Data Table();

params = Associative Array(Column(dt, "Parameter")) << get keys;

dts = {};

For Each({param}, params,
	cols_to_subset = {"Parameter"};
	Insert Into(cols_to_subset, param);
	cur_rows = dt << get rows where(:Parameter == param);
	dt_subset = dt << Subset(Rows(cur_rows), Selected Rows(0), Columns(cols_to_subset), Output Table("Parameter="||param));
	Insert Into(dts, dt_subset);
);

jthi_0-1736850380881.png

 

 

-Jarmo
PioJesudoss
Level II

Re: In a data frame Filter column based on another column that contains the column name

Thanks Jarmo.

 

I just starting jmp scripting and I need variablity chart as past of the for loop for each data table to save the image 

dts={};

For Each({param}, params,
	//cols_to_subset = {"Parameter"};
	cols_to_subset = {:Name("PRODUCT"), :Name("WAFER_LOT"), :Name("CHUNK"), :Name("WAFER_ID"),
	:Name("CHUNK_ID"),:Name("SLIDER_LOT"),:Name("TST_DATE"),:Name("WAFER_LOT"),:Name("FAIL_MODES"),:Name("DISPOSITION"),:Name("QTY_HGA"),
:Name("min_ET_date"),:Name("wafer_type"),:Name("wd_wafer_mfr_loc"),:Name("cq_or_child"),:Name("radius"),:Name("calc_sh_rd1"),
:Name("calc_sh_rd2"),:Name("CTQ_WRT_WDTH"),:Name("Parameter"),:Name("Product_waferID_Chunk_ID"),:Name("hga_tester_id")};
	Insert Into(cols_to_subset, param);
	//Insert Into(param,cols_to_subset);
	cur_rows = dt_tester << get rows where(:Parameter == param);
	dt_subset = dt_tester << Subset(Rows(cur_rows), Selected Rows(0), Columns(cols_to_subset) ,Output Table("Parameter="||param));
	//Insert Into(dts, dt_subset);
	//);
	
	
	//this part not working
	dt_subset << Variability Chart(
	Y(__params__),
	X( :WAFER_LOT, :CHUNK, :hga_tester_id ),
	Sigma Multiplier( 6 ),
	Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),
	Variability Analysis( Std Dev Chart( 0 ) ),
	SendToReport(
		Dispatch(
			{__Variability Chart__},
			"Variability Chart",
			FrameBox,
			{Row Legend(
				hga_tester_id,
				Color( 1 ),
				Color Theme( "JMP Default"(1) ),
				Marker( 0 ),
				Marker Theme( "" ),
				Continuous Scale( 0 ),
				Reverse Scale( 0 ),
				Excluded Rows( 0 )
			)}
		)
	)
)
);
PioJesudoss
Level II

Re: In a data frame Filter column based on another column that contains the column name

Thanks Jarmo.

 

But require to plot variability chart as part of the for loop to save the graph 

params = Associative Array(Column(dt, "Parameter")) << get keys;
dts = {};


For Each({param}, params,
	//cols_to_subset = {"Parameter"};
	cols_to_subset = {:Name("PRA"), :Name("WA"), :Name("CH"), :Name("WA_D"),
	:Name("CH_D"),:Name("SL_T"),:Name("TST_DATE"),:Name("IL_M"),:Name("QTY"),
:Name("W"),:Name("Parameter"),:Name("h_t_d")};
	Insert Into(cols_to_subset, param);
	cur_rows = dt << get rows where(:Parameter == param);
	dt_subset = dt << Subset(Rows(cur_rows), Selected Rows(0), Columns(cols_to_subset), Output Table("Parameter="||param));
	Insert Into(dts, dt_subset);

	
	Variability Chart(
	Y(__params__ ),
	X( :WA, :CH, :h_t_d ),
	Sigma Multiplier( 6 ),
	Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),
	Variability Analysis(__params__, Std Dev Chart( 0 ) ),
	SendToReport(
		Dispatch(
			{},
			"Variability Chart",
			FrameBox,
			{Row Legend(
				h_t_d,
				Color( 1 ),
				Color Theme( "JMP Default"(1) ),
				Marker( 0 ),
				Marker Theme( "" ),
				Continuous Scale( 0 ),
				Reverse Scale( 0 ),
				Excluded Rows( 0 )
			)}
		)
	)
)
	Pause()
	
	
);
jthi
Super User

Re: In a data frame Filter column based on another column that contains the column name

Are the variability plots the end goals you wish to have? Or do you need the subsets also for something else (you can most likely just create those variability plots from your original table with some scripting without creating the subsets)?

 

Which columns should be used as Y and X for the variability charts?

 

-Jarmo