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
kuanaunwei
Level III

How To remove rows on specific columns

kuanaunwei_0-1651137050019.png

Hi,

 

The above table is just an example of my data set. I have 100k rows and 500+ columns. My question is how to remove the "aaa" rows 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How To remove rows on specific columns

I am not sure what you want the final result to be.  If you want the resulting table to be:

txnelson_0-1651145520765.png

Names Default To Here( 1 );
dt = Current Data Table();

// Get all of the column names
colNameList = dt << get column names( string );

// Remove the first column name from the list
Remove From( colNameList, 1, 1 );

dt << Begin Data Update;

// Loop across all columns in the list and recode them
For( i = 1, i <= N Items( colNameList ), i++,
	dt << Recode Column(
		As Column( dt, colNameList[i] ),
		{Map Value( _rcOrig, {"aaa", " "}, Unmatched( _rcNow ) )},
		Update Properties( 1 ),
		Target Column( As Column( dt, colNameList[i] ) )
	)
);

dt << End Data Update;

If the final result is

txnelson_1-1651145633117.png

Names Default To Here( 1 );
dt = Current Data Table();

// Get all of the column names
colNameList = dt << get column names( string );

// Remove the first column name from the list
Remove From( colNameList, 1, 1 );

// Loop across all columns in the list and find rows 
// that have aaa for that column
For( i = 1, i <= N Items( colNameList ), i++,
	dt << select where(
		As Column( dt, colNameList[i] ) == "aaa",
		current selection( "extend" )
	)
);

// Delete all selected rows
dt << delete rows;

For future discussions where you provide an image of a data table, please insert it as a table and not as a picture of the table, or if possible attach the table.  This will remove the requirement of the responder to have to spend the time required to individually create the table(s).

 

Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: How To remove rows on specific columns

I am not sure what you want the final result to be.  If you want the resulting table to be:

txnelson_0-1651145520765.png

Names Default To Here( 1 );
dt = Current Data Table();

// Get all of the column names
colNameList = dt << get column names( string );

// Remove the first column name from the list
Remove From( colNameList, 1, 1 );

dt << Begin Data Update;

// Loop across all columns in the list and recode them
For( i = 1, i <= N Items( colNameList ), i++,
	dt << Recode Column(
		As Column( dt, colNameList[i] ),
		{Map Value( _rcOrig, {"aaa", " "}, Unmatched( _rcNow ) )},
		Update Properties( 1 ),
		Target Column( As Column( dt, colNameList[i] ) )
	)
);

dt << End Data Update;

If the final result is

txnelson_1-1651145633117.png

Names Default To Here( 1 );
dt = Current Data Table();

// Get all of the column names
colNameList = dt << get column names( string );

// Remove the first column name from the list
Remove From( colNameList, 1, 1 );

// Loop across all columns in the list and find rows 
// that have aaa for that column
For( i = 1, i <= N Items( colNameList ), i++,
	dt << select where(
		As Column( dt, colNameList[i] ) == "aaa",
		current selection( "extend" )
	)
);

// Delete all selected rows
dt << delete rows;

For future discussions where you provide an image of a data table, please insert it as a table and not as a picture of the table, or if possible attach the table.  This will remove the requirement of the responder to have to spend the time required to individually create the table(s).

 

Jim