title: Error while using Quandl library inside a def function
body: <p>I tried to use quandl inside a function to automize the process of getting stocks data.</p>
  <pre><code>import quandl
  import time
  
  quandl.ApiConfig.api_key = &quot;api_key&quot;
  
  
  def dataframe(ticker):
      data = quandl.get(f&quot;WIKI/{ticker}&quot;, start_date=&quot;2010.01.01&quot;, end_date=time.strftime(&quot;%Y.%m.%d&quot;, time.localtime()))
      data = data.iloc[:, :4]
      data.columns = [&quot;open&quot;, &quot;high&quot;, &quot;low&quot;, &quot;close&quot;]
  
      return data
  </code></pre>
  <p>I saved this part of the file as trade.py. Using Jupyter i can import the module by:</p>
  <pre><code>import trade 
  twtr = trade.dataframe(&quot;TWTR&quot;)
  </code></pre>
  <p>but when I try to run the second one it gives me this error:</p>
  <blockquote>
  <p>(Status 404) (Quandl Error QECx02) You have submitted an incorrect Dataset code. Please check your Dataset codes and try again.</p>
  </blockquote>
  <p>But The code works if used out of the def function and the module.
  I used PYCharm.</p>