동료가 파이썬에 데이터 테이블을 보내고, 파이썬 내에서 데이터를 수정하고, 수정 된 테이블을 반환하는 샘플이 있는지 묻습니다. 스크립팅 색인에서 하나도 찾지 못해 공유 할 색인을 만들었습니다.
이 스크립트는 완전한 왕복 여행을 보여줍니다. 데이터 테이블을 Python에 전달하고 Python에서 데이터를 수정 한 다음 결과를 JSL 스크립트로 반환합니다. 모두 좋아하는 데이터 표 사용하기 ... 빅 클래스. 이 스크립트는 테이블을 파이썬에 전달하고, 'lb_inch'와 같이 height 열로 나누어 진 가중치를 생성하고 수정 된 테이블을 JSL로 되돌려줍니다.
JMP가 데이터 테이블을 Python에 전달하면 Pandas 데이터 프레임이 Python 객체로 생성됩니다.
내 컴퓨터에는 여러 버전의 Python이 설치되어 있기 때문에 JMP에게 어디에서 사용하고 싶은 Python을 설치해야하는지 알려줘야한다. 이 작업은 Python Init 문으로 수행됩니다.
파이썬 초기화 (Path (), 파이썬 버전 사용 ())
Path ()는 파이썬 공유 라이브러리에 대한 경로입니다.
Use Python Version ()은 내가 원하는 파이썬 버전입니다.
Windows의 경우 c : \ anaconda3 \ ... \ python36.dll 대신 경로 구분 기호를 이스케이프하면 c : \\ anaconda3 \\ ... \\ python36.dll이됩니다. 파일 시스템 경로의 나머지 부분입니다.
이 Python Init ()은 Mac에서 Python을 설치하는 것을 가리 킵니다.
Names Default To Here( 1 );
Python Init(Path("/Library/Frameworks/Python.framework/Versions/3.6/lib/libpython3.6.dylib"),
Use Python Version("3.6")
);
dt1 = Open( "$SAMPLE_DATA/Big Class.jmp" );
Python Send( dt1 );
Close( dt1 );
Python Submit("print(dt1)");
Python Submit("\[
# The JMP Data table is transferred to Python as a pandas data frame
# Print out the column names
for col in dt1.columns:
print( col )
# Create a new column and apply formula to data, creating pounds per inch
# weight / height
def my_formula(w,h):
return w / h
dt1['lb_inch'] = dt1.apply(lambda row: my_formula(row['weight'],row['height']), axis=1)
dt1.head()<BR />
# print the modified table from Python
print(dt1)
]\");
<BR />// Get the modified table back from Python
dt2 = Python Get(dt1);
dt2 << New Data View;
Python Term();