Initializing help system before first use

pysetdf

Purpose
Convert a list of Mosel arrays to a pandas DataFrame.
Synopsis
procedure pysetdf(varname:string,input:list of array)
procedure pysetdf(varname:string,input:list of array,labels:list of string)
Arguments
varname 
Global Python variable name for the new DataFrame
input 
Mosel list of arrays to be converted to the DataFrame
labels 
Labels for the DataFrame columns
Example
In this example, two Mosel arrays with the same index sets are converted to a DataFrame. With the first call to pysetdf, a DataFrame is created with integer column labels and the second creates a DataFrame with string column labels.
declarations
    I, J: set of integer
    Numbers: dynamic array(I, J) of integer
    Labels: dynamic array(I, J) of string
end-declarations

pyinitpandas
Numbers(1,1) := 11;    Labels(1,1) := "eleven"
Numbers(2,3) := 23;    Labels(2,3) := "twenty-three"
Numbers(4,2) := 42;    Labels(4,2) := "forty-two"

writeln("Integer column labels:")
pysetdf("df", [Numbers, Labels])
pyexec("print(df)")

pysetdf("df", [Numbers, Labels], ["number", "label"])
writeln("\nString column labels:")
pyexec("print(df)")
Further information
1. The first version of the procedure creates a new DataFrame with numbers as column labels and the second version uses the provided string column labels.
2. The procedure creates or overwrites the global variable by writing the new value to the attributes of the Python __main__ module. If the variable name is not a valid Python variable identifier the procedure will succeed anyway and write the value to the module attributes using the name specified in varname.
3. The procedure replaces previously existing global variables. It does not update or add data to existing Python structures.
4. DataFrame conversion is supported in all module functions that accept lists of arrays. In particular, it is supported by pycall and the I/O Driver python .
Related topics
Module
python3

© 2001-2022 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.