title: Power BI: How to use Python with multiple tables in the Power Query Editor?
body: <p>How can you create a new table with a Python script that uses two existing tables as input? For example by performing a <code>left join</code> using <a href="https://pandas.pydata.org/pandas-docs/stable/merging.html" rel="noreferrer">pandas merge</a>?</p>
  
  <p><strong>Some details:</strong></p>
  
  <p>Using <code>Home &gt; Edit queries</code> you can utilize Python under <code>Transform &gt; Run Python Script</code>. This opens a <code>Run Python Script</code> dialog box where your're told that <code>'#dataset'  holds the input data for this script</code>. And you'll find the same phrase if you just click <code>OK</code> and look at the formula bar:</p>
  
  <p><code>= Python.Execute("# 'dataset' holds the input data for this script#(lf)",[dataset=#"Changed Type"])</code></p>
  
  <p>This also adds a new step under <code>Applied Steps</code> called <code>Run Python script</code> where you can edit the Python script by clicking the gear symbol on the right:</p>
  
  <p><a href="https://i.stack.imgur.com/YDiVK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YDiVK.png" alt="enter image description here"></a></p>
  
  <p><strong><em>How can you change that setup to reference more than one table?</em></strong></p>
  
  <hr>
  
  <p><strong>Sample data</strong></p>
  
  <p>Here are two tables that can be stored as CSV files and loaded using <code>Home &gt; Get Data &gt; Text/CSV</code></p>
  
  <p><strong>Table1</strong></p>
  
  <pre><code>Date,Value1
  2108-10-12,1
  2108-10-13,2
  2108-10-14,3
  2108-10-15,4
  2108-10-16,5
  </code></pre>
  
  <p><strong>Table2</strong></p>
  
  <pre><code>Date,Value2
  2108-10-12,10
  2108-10-13,11
  2108-10-14,12
  2108-10-15,13
  2108-10-16,14
  </code></pre>