cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to create experiments to support product design and ID useful product features. Register for June 12 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
powerpuff
Level IV

Min and Max values of all numeric columns

I am trying to extract minimum and maximum values from all numeric columns of a table. However, I also want the column name of which the values are extracted. 

Here is my script:

dt = Open("Path");
nc = N Row(dt);
mycol = dt << get column names;
//show(mycol);
for(i=1,i<=nc,i++,
If( x = Column( dt, i ) << get data type() == "Numeric",
myMax = col max(column(dt,i));
print("Max:",myMax);
myMin = col min(column(dt,i));
print("Min",myMin);
));

I also get the following JMP Alert when I run this script: 

Check script for using an assignment with single = where a test for equality with double == is normally expected. Expression is
"x = Column( dt, i ) << get data type() == "Numeric""

However, I am able to extract the min and max values. Can anyone point out as to how I can extract the names of those numeric columns as well and put that in a new table with Column Name, Min and Max values? Thanks.

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Min and Max values of all numeric columns

Try this one

Names Default To Here( 1 );
dt = Open( "path" );

For( i = 1, i <= N Col( dt ), i++,
	If( Column( dt, i ) << get data type == "Numeric",
		Write( "\!n", Column( dt, i ) << get name );
		Write( Column( dt, i ), "\!nMin: ", Col Min( Column( dt, i ) ) );
		Write( "\!nMax: ", Col Max( Column( dt, i ) ) );
	)
);
Jim

View solution in original post

uday_guntupalli
Level VIII

Re: Min and Max values of all numeric columns

@powerpuff,

 

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

NumericCols = {};
Minimums = {};
Maximums = {}; 

for(i = 1, i <= N Cols(dt), i++,
		Col = Column(dt,i);
		ColDataType = Col << Get Data Type; 
		If( ColDataType == "Numeric",
			Insert Into(NumericCols,Col << Get Name); 
			Insert Into(Minimums, Col Min(Col)); 
			Insert Into(Maximums, Col Max(Col)); 
		  );
   );
   
Show(NumericCols); 
Show(Minimums); 
Show(Maximums); 
Best
Uday

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: Min and Max values of all numeric columns

Try this one

Names Default To Here( 1 );
dt = Open( "path" );

For( i = 1, i <= N Col( dt ), i++,
	If( Column( dt, i ) << get data type == "Numeric",
		Write( "\!n", Column( dt, i ) << get name );
		Write( Column( dt, i ), "\!nMin: ", Col Min( Column( dt, i ) ) );
		Write( "\!nMax: ", Col Max( Column( dt, i ) ) );
	)
);
Jim
uday_guntupalli
Level VIII

Re: Min and Max values of all numeric columns

@powerpuff,

 

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

NumericCols = {};
Minimums = {};
Maximums = {}; 

for(i = 1, i <= N Cols(dt), i++,
		Col = Column(dt,i);
		ColDataType = Col << Get Data Type; 
		If( ColDataType == "Numeric",
			Insert Into(NumericCols,Col << Get Name); 
			Insert Into(Minimums, Col Min(Col)); 
			Insert Into(Maximums, Col Max(Col)); 
		  );
   );
   
Show(NumericCols); 
Show(Minimums); 
Show(Maximums); 
Best
Uday
KarenC
Super User (Alumni)

Re: Min and Max values of all numeric columns

For a non-JSL solution...

  1. From the columns red triangle in the colmns panel (left side of data table) select "Column Viewer".  
  2. Select the columns of interest
  3. Click on the "Show Quartiles" option
  4. Click Show Summary
  5. From the Summary Statistics red triangle menu select "Data Table View"
  6. Delete the columns you do not want.
  7. Done. 

Recommended Articles