---
schema_version: "1"
id: ed3a34fd9536da830dd32507c80e559947b5e717bb783442b66cde88142cc014
title: 在流程中使用 R 和 Python 指令碼
collection: tableau
version: next
locale: zh-tw
portal_url: https://docs.salesforce.com/tableau/next/zh-tw/prep/prep_scripts.md
canonical_url: https://help.tableau.com/v0.0/prep/zh-tw/prep_scripts.htm
source_site: help.tableau.com
content_type: documentation
content_hash: e9e3b021e8da9a189a08cfc522f8e055c6601613da849c3889636e2ce40ae24d
description: Overview about using R and Python scripts in a Tableau Prep flow for advanced operations.
---
[跳至主要內容](#main-content)

# 在流程中使用 R 和 Python 指令碼

從版本 2019.3.1 開始，您可以使用 R 和 Python 指令碼以執行更複雜的清除操作，或將預測的模組化資料整合到您的流程中。透過 R 或 Python 指令碼步驟從流程傳遞資料作為輸入，然後傳回作為輸出資料，您可以使用 Tableau Prep Builder 的特性和功能繼續清除該資料。

**附註：**尚未支援連接到指令碼作為流程的輸入步驟。此外，製作的流程或發佈到 Tableau Cloud 的流程尚不支援指令碼步驟。

![Tableau Prep 新增指令碼步驟。](/tableau/next/zh-tw/prep/zh-tw/Img/prep_script_step2.png)

設定 Rserve 伺服器或 Tableau Python (TabPy) 伺服器，並將指令碼步驟新增至流程。Tableau Prep 會將資料傳送至 Rserve（適用於 R）或 Tableau Python 伺服器 (TabPy)（適用於 Python），並以表格形式將結果資料傳回流程。您可以繼續將清除操作套用至結果，並產生輸出以進行分析。

當您建立指令碼時，需要包含指定資料框架作為函數引數的函數。如果要傳回的欄位與輸入的欄位不同，您需要在定義輸出和資料類型的指令碼中，包含 getOutputSchema 函數。否則，輸出將使用來自輸入資料的欄位。

若在 Tableau Server（版本 2020.4.1 及更高版本）中製作或編輯包含指令碼步驟的流程，則 Tableau Server 還必須與 Rserve 或 TabPy 伺服器建立連線，以執行指令碼步驟。有關如何設定 R 或 Python 以在流程中使用或如何建立指令碼的詳情，請參閱[在流程中使用 R (Rserve) 指令碼](https://help.tableau.com/v0.0/prep/zh-tw/prep_scripts._R.htm)或[在流程中使用 Python 指令碼](https://help.tableau.com/v0.0/prep/zh-tw/prep_scripts_TabPy.htm)。

需要協助偵錯流程嗎？嘗試從說明\>設定和效能功能表開啟啟用查詢記錄。有關詳情，請參閱[啟用查詢記錄](https://help.tableau.com/current/prep/zh-tw/prep_troubleshoot.htm#enable-query-logging)。

## 此區段的其他文章