<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Empty/Strange Python object after retrieving via Application Builder Script in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Empty-Strange-Python-object-after-retrieving-via-Application/m-p/773340#M95435</link>
    <description>&lt;P&gt;I don't see in your Application Builder script any &lt;STRONG&gt;Python Send(dt1);&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, that JMP 18 changes what happens with a &lt;STRONG&gt;Python Send(dt).&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;In JMP 18 and beyond, you get a jmp.DataTable object instead of a pandas.DataFrame.&amp;nbsp; And that DataTable object is no longer a copy of the data but live access to&amp;nbsp;&lt;STRONG&gt;the&lt;/STRONG&gt; data table, you can do processing in Python directly on the live table.&amp;nbsp; See the &lt;STRONG&gt;Scripting Index&lt;/STRONG&gt; in JMP 18 for examples of the Python APIs supported via the &lt;STRONG&gt;import jmp&lt;/STRONG&gt; package.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to go from jmp.DataTable to pandas.DataFrame there are several examples in the $SAMPLE_SCRIPTS/Python directory.&amp;nbsp; dt2pandas.py does exactly what JMP 14-17 did, save the DataTable to disk as a temporary CSV file, the tell pandas to read_csv() on the file.&amp;nbsp; JMP2pandas.py is an example script showing how to use the capabilities of the jmp.DataTable object and create a pandas.DataFrame in memory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Python Get( dt ) recognizes the new jmp.DataTable object, while Python Get( df ) will recognize the DataFrame and import using CSV the same as JMP 14-17&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jul 2024 14:10:21 GMT</pubDate>
    <dc:creator>Paul_Nelson</dc:creator>
    <dc:date>2024-07-16T14:10:21Z</dc:date>
    <item>
      <title>Empty/Strange Python object after retrieving via Application Builder Script</title>
      <link>https://community.jmp.com/t5/Discussions/Empty-Strange-Python-object-after-retrieving-via-Application/m-p/773164#M95397</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(JMP 17 Pro user) I am encountering a strange issue when attempting to pass data table objects to Python and retrieve them back into JSL, specifically while using Application Builder.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As this is the first time I've used Application Builder, I wrote out a rough draft of the behavior I wanted in the app via a standard JSL script (for context, the goal is an application that allows user to select directory/file, then let JMP generate a graph for analysis). The behavior works in a standard JSL script, but does not work within the Application Builder.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my standalone (non-Application Builder) script:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Initialize Python within JMP
PyConnect = Python Connect();

Names Default to Here( 1 );

// Allow user to manually pick directory and file
directory = Pick Directory ("Select a directory.");
chosen_file = Pick File("Select a file", directory);

// Open the selected file, then send to Python
dt1 = Open(chosen_file, Table Contains Column Headers(0));
Python Send(dt1);

// Close the dirty data table to save space/resources
Close(dt1, NoSave);

show(dt1, "first");

// Clean the table by removing all references to "#"
Python Submit("\[

dt1 = dt1[~dt1["Column 1"].str.contains("#")]

]\");

// Retrieve the processed table from Python and open in JMP
// Terminate Python connection
dt1 = Python Get(dt1);
Python Term();

show(dt1, "second");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And the output for this script:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt1 = DataTable("D424TUZ0.Inspec Meas 01");
"first";

dt1 = DataTable("dt1");
"second";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(NOT WORKING) Here's my Application Builder script:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;executePress=Function({thisBox}, {Default Local},
	// This function is called when the button is pressed
	py = Python Connect();

	dt1 = Open(::file, Table Contains Column Headers(0));
	
	Close(dt1, NoSave);
	
	show(dt1, "first");
	
	// Clean the table by removing all references to "#"
	Python Submit("\[

	dt1 = dt1[~dt1["Column 1"].str.contains("#")]

	]\");
	
	dt1 = Python Get(dt1);
	Python Term();
	
	show(dt1, "second");
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and the troubling output:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt1 = DataTable("D424TUZ0.Inspec Meas 01");
"first";
/**********/


	dt1 = dt1[~dt1["Column 1"].str.contains("#")]

	
/**********/
dt1 = .;
"second";&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;TLDR: in my standalone script, after retrieving my data table back from cleaning in Python via &lt;STRONG&gt;dt1 = Python Get(dt1);&lt;/STRONG&gt;, I get back an object as&amp;nbsp;&lt;STRONG&gt;dt1 = DataTable("dt1");&lt;/STRONG&gt;. However in JMP Application Builder script, I get &lt;STRONG&gt;dt1 = .;&lt;/STRONG&gt; (which to me indicates that the object doesn't exist?).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I first recognized this when I attempted to use &lt;STRONG&gt;dt1 &amp;lt;&amp;lt; New Data Window;&amp;nbsp;&lt;/STRONG&gt;and reading this thread made me realize that I likely am not working with an object at all:&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discussions/Error-in-running-script-Send-Expects-Scriptable-Object-in-access/td-p/718245" target="_blank"&gt;https://community.jmp.com/t5/Discussions/Error-in-running-script-Send-Expects-Scriptable-Object-in-access/td-p/718245&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies for the long post. It's a strange error, and thank you to anybody in advance for your help on this problem!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2024 23:24:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Empty-Strange-Python-object-after-retrieving-via-Application/m-p/773164#M95397</guid>
      <dc:creator>CircularHazard2</dc:creator>
      <dc:date>2024-07-15T23:24:02Z</dc:date>
    </item>
    <item>
      <title>Re: Empty/Strange Python object after retrieving via Application Builder Script</title>
      <link>https://community.jmp.com/t5/Discussions/Empty-Strange-Python-object-after-retrieving-via-Application/m-p/773340#M95435</link>
      <description>&lt;P&gt;I don't see in your Application Builder script any &lt;STRONG&gt;Python Send(dt1);&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, that JMP 18 changes what happens with a &lt;STRONG&gt;Python Send(dt).&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;In JMP 18 and beyond, you get a jmp.DataTable object instead of a pandas.DataFrame.&amp;nbsp; And that DataTable object is no longer a copy of the data but live access to&amp;nbsp;&lt;STRONG&gt;the&lt;/STRONG&gt; data table, you can do processing in Python directly on the live table.&amp;nbsp; See the &lt;STRONG&gt;Scripting Index&lt;/STRONG&gt; in JMP 18 for examples of the Python APIs supported via the &lt;STRONG&gt;import jmp&lt;/STRONG&gt; package.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to go from jmp.DataTable to pandas.DataFrame there are several examples in the $SAMPLE_SCRIPTS/Python directory.&amp;nbsp; dt2pandas.py does exactly what JMP 14-17 did, save the DataTable to disk as a temporary CSV file, the tell pandas to read_csv() on the file.&amp;nbsp; JMP2pandas.py is an example script showing how to use the capabilities of the jmp.DataTable object and create a pandas.DataFrame in memory.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Python Get( dt ) recognizes the new jmp.DataTable object, while Python Get( df ) will recognize the DataFrame and import using CSV the same as JMP 14-17&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2024 14:10:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Empty-Strange-Python-object-after-retrieving-via-Application/m-p/773340#M95435</guid>
      <dc:creator>Paul_Nelson</dc:creator>
      <dc:date>2024-07-16T14:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Empty/Strange Python object after retrieving via Application Builder Script</title>
      <link>https://community.jmp.com/t5/Discussions/Empty-Strange-Python-object-after-retrieving-via-Application/m-p/773345#M95438</link>
      <description>&lt;P&gt;Thank you so much for your detailed solution, this was very helpful. I can't believe I missed something so small.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2024 15:12:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Empty-Strange-Python-object-after-retrieving-via-Application/m-p/773345#M95438</guid>
      <dc:creator>CircularHazard2</dc:creator>
      <dc:date>2024-07-16T15:12:34Z</dc:date>
    </item>
  </channel>
</rss>

