Closed knozaw closed 5 years ago
@knozaw As specified in the documentation at https://github.com/tableau/TabPy/blob/master/docs/TableauConfiguration.md#anatomy-of-a-python-calculation you need to use positional arguments in your Python script as _arg1
, _arg2
, etc. When the script is passed to TabPy there is no notion of fields, columns or anything like that.
@knozaw this video should also help answer some of your questions: https://youtu.be/nRtOMTnBz_Y
Thank you, @0golovatyi and @nmannheimer.
I looked at those documents and YouTube video. It helped me writing a script in tableau.
However, exactly the same code in Jupyter gives me "True" output, but TabPy gives me an error message.
Did anyone had the similar issue?
Sincerely, knozawa
My guess is pd.read_csv
created different frame then pd.DataFrame
.
@knozaw your script needs to have a return value, so try adding: return nx.has_path(....
Thank you, @0golovatyi and @nmannheimer.
I've added return in front of the nx.has_path
However, I received the same issue:
@knozaw it looks like your parameter you are passing is a string, but in your jupyter code, you are looking for integers. What happens if you convert the parameter type in Tableau to integer, or convert the strings in your python code to ints?
Instead of using os.chdir
does it work if you specify the full path to the file in pd.read_csv
? The error is getting raised by networkx and if it works on a Jupiter notebook but not on Tableau server I would guess that os.chdir
isn't doing what you expect it to on TabPy
@knozaw Has the issue been resolved or you are still experiencing it?
Hello,
Sorry. I hadn't had a chance to test converting the parameter type and pd.read_csv yet. I'll get back to this once as soon as possible.
Thank you all for your kind help!
Sincerely, knozawa
@nmannheimer - I tested converting str to int in tableau, but it didn't work either.
@WillAyd - pd.read_csv worked on jupyter.
When I tried to filter by the calculation in tableau, I received this error message:
It seems like pandas.DataFrame
is not working correctly in tableau.
Sincerely, knozawa
@WillAyd - pd.read_csv worked on jupyter.
Did you specify a full path to the file in read_csv in both Jupyter and TabPy? Using os.chdir
may seemingly be fragile on the TabPy side since you are relying on the server to actually execute that and update the current directory, which it might not guarantee execution of. If you use an absolute path in TabPy you would remove that confounding factor
Hi @WillAyd,
No. At first, I specified the full path using the os.chdir
in the Jupyter Lab. But next, I uploaded the csv file into the Jupyter Lab and used the pd.read_csv("ToFrom.txt", delimiter = '\t')
to read the file on the Jupyter Lab. Both ways worked on Jupyter Lab.
I didn't use the full path on TabPy. I read the data from Tableau data source using df = pd.DataFrame({'source':_arg1,'target':_arg2})
.
According to the command prompt, I'm getting 500 post error (internal server error) message.
Sincerely, knozawa
Are you sure your dtypes are consistent across both sources? What is the output of df.dtypes
in Jupyter?
Hi @WillAyd,
Yes, I believe so.
os.char
pd.read_csv
Tableau
The data type is integers for all data sources.
Sincerely, knozawa
In Tableau your data type is string. Does changing that to a number resolve?
Hello,
I've received an Invalid Syntax Error in tableau calculation:
When I looked at the tableau calculation, the line 8 is:
print([p for p in nx.shortest_path(G,source=[Source Parameter],target=[Target Parameter])])
Here is the original script written in JupyterLab:
In tableau calculation, I've updated the source and target value to be dynamically changed using [Source Parameter] and [Target Parameter].
The [Source Parameter] uses the field list "From".
The [Target Parameter] uses the field list "To".
Does anyone know how to translate the python script for tableau calculation?
Sincerely, knozawa