I have files in a repo with the following Structure:
RepoName\main.py
RepoName\functions\myfunction.py
Inside myfunction.py is:
import pandas as pd
def make_ticker_list():
constituents = pd.read_csv("myfile.csv")
ticker_list = ""
for x in constituents:
ticker_list = ticker_list + x + " "
del x
return ticker_list
and inside main.py is:
import pandas as pd
from functions.myfunction import *
new_list = make_ticker_list()
but when I run main.py, I get:
NameError: name 'pd' is not defined
I've imported the pandas alias already in main.py so I don't know why I get this error. I added it to myfunction.py as shown above, but that also didn't work
Tried so far and didn't work:
- Adding import pandas as pd into the myfunction.py file, as shown above
- Adding a '
__init__.py' into the functions folder
The logic makes sense because when I load another toy function into myfunction.py, eg:
def toy()
return 2
And I run toy() in main.py, it works fine
Any ideas what the problem might be?