Hi I am trying to create a macro using python code which will perform text to column and then rows.
I have written the code in python however my input is not getting processed.
My code doesn't the input value I give through action
My code:
#################################
# List all non-standard packages to be imported by your
# script here (only missing packages will be installed)
from ayx import Package
#Package.installPackages(['pandas','numpy'])
#################################
from ayx import Alteryx
df=Alteryx.read('#1')
x=Alteryx.read('#2')
y=Alteryx.read('#3')
#################################
import pandas as pd
#################################
split=df[x].str.split(y,expand=True).add_prefix(x)
split
#################################
combine=pd.concat([df, split],axis=1)
combine
#################################
texttoRow=pd.melt(combine[combine.columns], id_vars=combine[df.columns]).dropna(axis=0,subset=['value'])
texttoRow
#################################
Alteryx.write(texttoRow,1)
Solved! Go to Solution.
Hello @Sivarubiny:
The Python Tool can only read incoming data connections using the Alteryx.read() method. You could configure the Action tools to update specific variables in your code but I have attached a screenshot of a solution that will be simpler to implement. If you configure the Interface tools to update a cell in a Text Input tool, you can then read the values in as panda data frames.
If you want to get rid off the python error no valid metadata you can encapsulate the python script into a macro following the steps I describe in this article: Python macros in Alteryx, how to get rid of the valid metadata error | by Alberto Hernández | Medium