<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to get a variable from one Notebook into another in Pipelines</title>
    <link>https://community.fabric.microsoft.com/t5/Pipelines/How-to-get-a-variable-from-one-Notebook-into-another/m-p/4397189#M7017</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="710370" data-lia-user-login="CrhIT" class="lia-mention lia-mention-user"&gt;CrhIT&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The `%run` magic command allows you to execute another notebook within the same workspace and access its variables directly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notebook1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import pandas as pd&lt;/P&gt;&lt;P&gt;data = {&lt;BR /&gt;"ID": [1, 2, 3, 4, 5],&lt;BR /&gt;"Name": ["Alice", "Bob", "Charlie", "David", "Eve"],&lt;BR /&gt;"Age": [25, 30, 35, 40, 45],&lt;BR /&gt;"Salary": [50000, 60000, 70000, 80000, 90000],&lt;BR /&gt;"Department": ["HR", "IT", "Finance", "Marketing", "Sales"]&lt;BR /&gt;}&lt;BR /&gt;df = pd.DataFrame(data)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Notebook_2, use `%run` to call Notebook_1:&lt;BR /&gt;%run Notebook_1&lt;BR /&gt;print(df.head())&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This method works only if both notebooks are in the same workspace.&lt;BR /&gt;• Variables defined in Notebook_1 will be available in Notebook_2&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;You can use&amp;nbsp;`mssparkutils.notebook.run()`&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Hope this is helpful.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;please accept the answer and give kudos if this helps&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2025 22:29:23 GMT</pubDate>
    <dc:creator>nilendraFabric</dc:creator>
    <dc:date>2025-02-05T22:29:23Z</dc:date>
    <item>
      <title>How to get a variable from one Notebook into another</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-to-get-a-variable-from-one-Notebook-into-another/m-p/4396858#M7015</link>
      <description>&lt;P&gt;I'm running a notebook, which output needs to be stored and used in a new notebook. How can this be done?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say in Notebook_1 the code is&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import pandas as pd

# Create an example pandas DataFrame
data = {
    "ID": [1, 2, 3, 4, 5],
    "Name": ["Alice", "Bob", "Charlie", "David", "Eve"],
    "Age": [25, 30, 35, 40, 45],
    "Salary": [50000, 60000, 70000, 80000, 90000],
    "Department": ["HR", "IT", "Finance", "Marketing", "Sales"]
}

df = pd.DataFrame(data)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to reference df in a new notebook so I have no need to rewrite the whole code in the new notebook.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 17:17:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-to-get-a-variable-from-one-Notebook-into-another/m-p/4396858#M7015</guid>
      <dc:creator>CrhIT</dc:creator>
      <dc:date>2025-02-05T17:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a variable from one Notebook into another</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-to-get-a-variable-from-one-Notebook-into-another/m-p/4397189#M7017</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="710370" data-lia-user-login="CrhIT" class="lia-mention lia-mention-user"&gt;CrhIT&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The `%run` magic command allows you to execute another notebook within the same workspace and access its variables directly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notebook1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import pandas as pd&lt;/P&gt;&lt;P&gt;data = {&lt;BR /&gt;"ID": [1, 2, 3, 4, 5],&lt;BR /&gt;"Name": ["Alice", "Bob", "Charlie", "David", "Eve"],&lt;BR /&gt;"Age": [25, 30, 35, 40, 45],&lt;BR /&gt;"Salary": [50000, 60000, 70000, 80000, 90000],&lt;BR /&gt;"Department": ["HR", "IT", "Finance", "Marketing", "Sales"]&lt;BR /&gt;}&lt;BR /&gt;df = pd.DataFrame(data)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Notebook_2, use `%run` to call Notebook_1:&lt;BR /&gt;%run Notebook_1&lt;BR /&gt;print(df.head())&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;This method works only if both notebooks are in the same workspace.&lt;BR /&gt;• Variables defined in Notebook_1 will be available in Notebook_2&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;You can use&amp;nbsp;`mssparkutils.notebook.run()`&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Hope this is helpful.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;please accept the answer and give kudos if this helps&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 22:29:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-to-get-a-variable-from-one-Notebook-into-another/m-p/4397189#M7017</guid>
      <dc:creator>nilendraFabric</dc:creator>
      <dc:date>2025-02-05T22:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to get a variable from one Notebook into another</title>
      <link>https://community.fabric.microsoft.com/t5/Pipelines/How-to-get-a-variable-from-one-Notebook-into-another/m-p/4397983#M7020</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="710370" data-lia-user-login="CrhIT" class="lia-mention lia-mention-user"&gt;CrhIT&lt;/a&gt;&amp;nbsp;if this is helpful , please accept the answer as it will help community to find the right information quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2025 10:16:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Pipelines/How-to-get-a-variable-from-one-Notebook-into-another/m-p/4397983#M7020</guid>
      <dc:creator>nilendraFabric</dc:creator>
      <dc:date>2025-02-06T10:16:49Z</dc:date>
    </item>
  </channel>
</rss>

