cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
] />

Discussions

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

Python integration get column properties

Hi,

Is there a way to get column properties from JMP data table (such as "Design role" and "Factor changes") in python, if I use df = jmp.current() as a reference to the opened JMP data table?
I am aware of df[0].dtype and df[0].mtype to get data type and modeling type properties, but I would like to list the factors and responses in python from a DoE generated table.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Python integration get column properties

You get None because you don't have access to here namespace. You can use Python Send

import jmp

jmp.open(jmp.SAMPLE_DATA + 'Big Class.jmp')

df = jmp.current()
jmp.run_jsl('''
dt = Python Get(df);
cname = dt << Get Column Names("string");
Python Send(cname);
''')

print(cname) # ['name', 'age', 'sex', 'height', 'weight']
-Jarmo

View solution in original post

12 REPLIES 12
jthi
Super User

Re: Python integration get column properties

You can always fallback to run_jsl if some feature hasn't yet been implemented

-Jarmo
aatw
Level III

Re: Python integration get column properties

Sure, however the following code:

df = jmp.current()
sc = jmp.run_jsl('df << Get Column Names();')
print(sc)

returns the following error: Name Unresolved: df in access or evaluation of 'df' , df/*###*/

Any ideas? 

jthi
Super User

Re: Python integration get column properties

JMP side doesn't know about your df python variables unless you "share" them. No idea what is preferred method, but you can for example use jmp.here

 

import jmp

dt = jmp.open(jmp.SAMPLE_DATA + 'Big Class.jmp')

jmp.here["dt"] = dt

jmp.run_jsl('''
	Names Default To Here(1);
	p = Column(dt, "name") << Get Property("Notes");	
'''
);

print(jmp.here.get('p'))

Or you could use Python Get from JMP side of things

 

 

import jmp

dt = jmp.open(jmp.SAMPLE_DATA + 'Big Class.jmp')

jmp.run_jsl('''
	dtref = Python Get(dt);
	p1 = Column(dtref, "name") << Get Property("Notes");	
'''
);

print(jmp.here.get('p1'))

 

 

 

-Jarmo
aatw
Level III

Re: Python integration get column properties

Very useful, thanks. Although when running:

df = jmp.current()
jmp.run_jsl('''
dt = Python Get( df );
cname = dt << Get Column Names();
''')
print(jmp.here.get('cname'))

I get "None" as output, despite obviously having some columns in my table.

Also, if using the script with "Names Default To Here(1)", my JMP crashes...

jthi
Super User

Re: Python integration get column properties

You get None because you don't have access to here namespace. You can use Python Send

import jmp

jmp.open(jmp.SAMPLE_DATA + 'Big Class.jmp')

df = jmp.current()
jmp.run_jsl('''
dt = Python Get(df);
cname = dt << Get Column Names("string");
Python Send(cname);
''')

print(cname) # ['name', 'age', 'sex', 'height', 'weight']
-Jarmo
aatw
Level III

Re: Python integration get column properties

Many thanks jthi!
This works, not only due to using Python Send (because I tried that before), but also due to specifying "string" type for cname.

aatw
Level III

Re: Python integration get column properties

Another question/wish: how would one scroll through all columns and check whether they have a "Design Role" or "Factor Changes" property, and list only those columns? 

jthi
Super User

Re: Python integration get column properties

Do you want the result in Python list if one of those properties is found for the columns?

-Jarmo
aatw
Level III

Re: Python integration get column properties

Yes

Recommended Articles