title: Importing a function from another file, where to import other libraries?
body: <p>Simple question, I've searched to no avail. Say I have a file "funcs.py", in it there's a function I want to call into my current script. The function uses another library (e.g. pandas), where do I import that library? What's the convention?</p>
  
  <p>Do I put it inside the function in funcs.py?</p>
  
  <pre><code>#funcs.py
  def make_df():
      import pandas as pd
      return pd.DataFrame(index=[1,2,3],data=[1,2,3])
  </code></pre>
  
  <p>Do I put it <em>outside</em> the function in funcs.py?</p>
  
  <pre><code>#funcs.py
  import pandas as pd
  
  def make_df():
      return pd.DataFrame(index=[1,2,3],data=[1,2,3])
  </code></pre>
  
  <p>Or do I put it in the current script I'm using?</p>
  
  <pre><code>#main.py
  import pandas as pd
  
  from funcs import make_df
  
  df = make_df()
  </code></pre>
  
  <p>Thanks and kind regards.</p>