title: Imported function acts differently than one written in the same file
body: <p>I have this structure:</p>
  <pre><code>Folder_1
      - Scripts
          - functions
              - data_import.py
          - main_notebook.ipynb
      - Data
          sales_data_1.csv
      - SQL
          - sales_data_1.sql
          - sql_2.sql
  </code></pre>
  <p>Inside <code>data_import.py</code> I have this function:</p>
  <pre><code>import os
  import pandas as pd
  import numpy as np
  import psycopg2 as pg
  
  sql_path = r&quot;C:Folder_1\SQL/&quot; # path to local sql folder
  data_path = r&quot;C:Folder_1\Data/&quot; # path to local data folder
  
  conn = pg.connect(
      dbname=&quot;db&quot;,
      host=&quot;host&quot;,
      user=&quot;user&quot;,
      password=&quot;pw&quot;,
      port=&quot;port&quot;,
  )
  
  conn.set_session(autocommit=True)
  
  
  def get_data(sql_file_name):
      # if file already exists, load it
      if os.path.isfile(f'{data_path}{sql_file_name}.csv'):
          df = pd.read_csv(f'{data_path}{sql_file_name}.csv')
          return df
  
      # otherwise, create it
      else:
          # get data from the internet
          query = open(f'{sql_path}{sql_file_name}.sql', 'r').read()
          df = pd.read_sql_query(query,conn)
  
          # save it to a file
          df.to_csv(f'{data_path}{sql_file_name}.csv', index=False)
  
          # return it
          return df
      
  </code></pre>
  <p>In my <code>main_notebook.ipynb</code> I import the <code>functions</code> like so:</p>
  <pre><code>from functions import data_import as jp
  </code></pre>
  <p>When I am trying to use it like this:</p>
  <p><code>sales_data = jp.get_data('sales_data_1')</code>
  I get this:</p>
  <p><a href="https://i.stack.imgur.com/A8EPm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A8EPm.png" alt="enter image description here" /></a></p>
  <p>But when I use the same, identical function in my <code>main_notebook.ipynb</code> ( with the imports and connections above ) I do get the actual <code>df</code> loaded if the file is not present in the <code>data</code> folder, the function correctly loads the query, saves the <code>.csv</code> file inside <code>Data</code> folder for the next use.</p>
  <p><code>sales_data = get_data('sales_data_1') # does work as expected</code></p>
  <p>But when I use it after importing it provides me with the query instead the actual <code>pd.DataFrame</code>. I am not sure where is my mistake, the goal is that the function inside the module <code>data_import</code> would work exactly as if it would be written in the <code>main_notebook.ipynb</code> file.</p>