LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unpack pandas df or list of lists with Labview Python Integration Toolkit

How do you unpack a pandas dataframe?

 

From unpack module I wired from "Python Object References Out" (PORO) to "Variant to Data". Then "Variant to Data" to a 2D array. The (PORO) polymorph is set to variant. 

 

As this wasn't working, I then tried just having my python function output a list of lists instead of a dataframe. I.e. return [[1.0,2,3,4],[2.0,7,8,9]]. Still no luck

 

But if I just return a double single output, change the polymorph and wire value to double indicator, the program works fine. I.e. return 2

 

I still cannot unpack correctly using enthought python development kit for labview. I furthermore cannot find any examples.

 

Example labview vi included. Here is the basic python code:

 

def df(num):

    some_list = []

    another_list = []

    for i in range(num):

        some_list.append(i)

        another_list.append(i)

    #return [some_list, another_list] <-- I cannot unpack this correctly

    return some_list     #no problem unpacking this in labview

0 Kudos
Message 1 of 3
(4,330 Views)

If a community member doesn't know, you could try reaching out to Enthought product support as well.

 

https://support.enthought.com/hc/en-us

Message 2 of 3
(4,269 Views)

scr,

 

Dataframes and lists (and lists of lists) are data types specific to Python. LabVIEW does not inherently have any of these data types. The closest thing in LabVIEW to this would be arrays, and arrays of arrays.

 

According to Enthought's Getting Started Guide, NumPy arrays are the only type of array supported by the Python/LabVIEW bridge. To achieve your 'list of lists' with the Python Integration Toolkit, we'll want to return a multidimensional array of arrays in Python (save the attached text file as a Python file), and we can unpack the data as a variant and convert that 'value' output to a 2D (or more) array. 

 

unpack_2D_array.png

 

To reiterate, this is Enthought's product and you should contact them for help as titen said, this just sparked my interest.

 

Hope this helps, big guy.

 

BrandonN

 

Message 3 of 3
(4,251 Views)