Skip to content

Tableau's documentation adjustments (Tableau communicates with Python by lists) #99

@lojacobs

Description

@lojacobs

By playing around, I discovered that the documentation in Tableau isn't up to date.

The examples aren't working because in Python 3.6, the "map" function return a map object whereas Tableau need to receive a list. Thus, we need to list( ) the map function to return a list.

Also, It should be good to demonstrate how to use Tableau's Parameters.

In my example below, the [Filter for regex] is a String Parameter inside Tableau. Because Tableau send to Python the parameter as a list with the same value for every row in the visual, we need to limit the parameter to only 1 variable with the [0] to get the first argument of the list.

SCRIPT_BOOL(
"import re
return list(map(lambda x: bool(re.search(_arg1[0],x)),_arg2))
",[Filter for regex],Attr([Customer Name])
)

From this experimentation, I assume that Tableau will always want to receive a list back to match the rows as well as will always send to Python lists. (so, we have to adjust in Python for that)

PS: it's easier to use the Tableau's regex functions but it's a good way to test the way Tableau is working with Python ;-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions