Dynamo+Python+Pandas not working

Hi,
a few comments

  • if you use the raw string it is not necessary to put the double \\

  • it is strongly recommended to use the dynamo Python directory to install packages (where the sdtlib is located)
    see this page
    and
    see this topic

  • the OUT variable that passes through the dynamo wrapper does not allow displaying a complete dataframe (try to convert to List),

some solutions to watch a dataframe

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('Python.Included')
import Python.Included as pyInc
path_py3_lib = pyInc.Installer.EmbeddedPythonHome
sys.path.append(path_py3_lib + r'\Lib\site-packages')

import pandas as pd

d = {'col1': [1, 2, 3], 'col2': [3, 4, 5], 'id' : [1233, 3445, 7786]}
df = pd.DataFrame(data=d)
df = df.set_index('id')

# solution 1 to display in the console
print(df)
#
# solution 2 converting to a string reprensation at OUT variable
OUT = repr(df)

you can also convert to an array (without the index)

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('Python.Included')
import Python.Included as pyInc
path_py3_lib = pyInc.Installer.EmbeddedPythonHome
sys.path.append(path_py3_lib + r'\Lib\site-packages')

import pandas as pd

d = {'col1': [1, 2, 3], 'col2': [3, 4, 5], 'id' : [1233, 3445, 7786]}
df = pd.DataFrame(data=d)
df = df.set_index('id')

OUT = df.to_numpy()
4 Likes