The current documentation of Python Get() states that :
It would be helpful to add the ability to also retrieve dictionaries from Python. Dictionaries are commonly used in Python and will easily translate into Associative Arrays in JMP.
The Python Get() function will return a dictionary. We'll work on updating the documentation. Here's an example.
//
// JSL / Python
// Script to take a Pandas Data frame and bring back as a
// JMP Associative Array, this does not use an intermediate csv file
// to transfer from Python to JMP
//
// Date: 20 Jun 2018
// Author: Paul Nelson
//
Python Init();
Python Submit("\[
import pandas as pd
import numpy as np
print('Pandas Version: ' + pd.__version__)
data =
{'state':['Ohio','Ohio','Ohio','Nevada','Nevada','Nevada'],'year':[2000,2001,200
2,2001,2002,2003], 'pop':[1.5,1.7,3.6,2.4,2.9,3.2]
}
df = pd.DataFrame(data)
print(df)
v = df.values
print(v)
cols = df.columns
types = [(cols[i], df[k].dtype.type) for (i, k) in enumerate(cols)]
dtype = np.dtype(types)
array = np.zeros(v.shape[0], dtype)
for (i, k) in enumerate(array.dtype.names):
array[k] = v[:, i]
print(array.dtype.names);
print(array)
d={}
l=[]
for (i, k) in enumerate(array.dtype.names):
d[k] = v[:,i].tolist()
print(d)
print('leaving python')
]\");
Print("inJSL");
pyData = Python Get(d);
Print(pyData);
Python Term();