The following example sends the JMP x and y variables to Python, executes the Python statement z <- x * y, and then gets the Python z variable and returns it to JMP.
Python Init();
x = [1 2 3];
Python Send( x );
y = [4 5 6];
Python Send( y );
Python Submit( "\[
import numpy as np
p = np.multiply(x, y) # matrix product
]\" );
p = Python Get( p );
Show( p );
Python Term();
p = [4 10 18];
0
Python Init(); // initiate the Python connection
qbx = "The right stuff";
Python Send( qbx );
// send the qbx variable and sample data table "Animals.jmp" to Python
dt = Open( "$SAMPLE_DATA/Animals.jmp" );
Python Send( dt );
Close( dt, nosave );
qbx = Python Get( qbx );
// get the Python variable qbx and place it into a JMP variable qbx
df = Python Get( dt );
/* get the Python variable dt and place it into a JMP data table
referenced by df */
Python Term();
Show( qbx );
df << New Data View;
Wait( 10 );
Close( df, nosave );
Python Term();
qbx = "The right stuff";
0
Optional. Performs an Eval Insert() on the Python code before submission.
Python Init(); // initiate the Python connection
commands =
"
friends = ['john', 'pat', 'gary', 'michael']
print(friends)
for i, name in enumerate(friends):
print( \!"iteration {iteration} is {name}\!".format(iteration=i, name=name))
";
Python Submit( commands );
Python Term();
['john', 'pat', 'gary', 'michael']
iteration 0 is john
iteration 1 is pat
iteration 2 is gary
iteration 3 is michael
0