Reputation: 13
I have this sentence in my main.py
file:
import pandas as pd
from modules.my_self_defined import *
input='1.csv'
df=just_an_example(input)
in ./modules/my_self_defined.py:
def just_an_example(csv_file):
a=pd.read_csv(csv_file)
return a
Then when I run the file, it says pd is not defined in ./modules/my_self_defined.py
How could I make it work?
Upvotes: 1
Views: 73
Reputation: 12140
You use pandas (pd) in my_self_defined.py
, not in main.py
. So import it in my_self_defined.py
instead and it'll work.
Upvotes: 1