I use package uipath.python.activities. , and during activity " invoke python method" , I wish to pass in argument a datatable. So that the python method can add a new column to it, based on an existing column.
However, it promts error, says datatable not serializatible, Anyone can help?
Convert the data table to csv
using Output Data Table Activity
. Now you can consume the csv
from Python script.
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html
Dear Kannan:
Thanks a lot for your tip.
I have a question. When using output data table activity, the datatable is converted into a string, however, in pandas, the method read_csv takes file path of csv as argument, rather than the content of csv itself .
So I cannot figure out how to get your tip work ,can you kindly please help .Thx.
Bob Qian
Refer the code below form stackoverflow.
import sys
if sys.version_info[0] < 3:
from StringIO import StringIO
else:
from io import StringIO
import pandas as pd
TESTDATA = StringIO("""col1;col2;col3
1;4.4;99
2;4.5;200
3;4.7;65
4;3.2;140
""")
df = pd.read_csv(TESTDATA, sep=";")
Note: The separator used above is ;
. In your case it might be ,
.
Another option would be to write the text to a csv file and then use that file path as input to your python script.