Skip to content Skip to sidebar Skip to footer

Is Pandas Not Importing? 'NameError: Global Name 'pandas' Is Not Defined'

I'm getting a few errors here but I think it's due to pandas not importing as it's greyed out. If that is the problem, how would I fix this? C:\Anaconda\python.exe C:/Users/nick

Solution 1:

You have imported it as

import pandas as pd

and calling

#pandas
df = pandas.DataFrame(columns = ['Date','Unix','Ticker','DE Ratio'])

You could either change

  • import pandas as pd to import pandas or
  • df = pandas.DataFrame(columns = ['Date','Unix','Ticker','DE Ratio']) to df = pd.DataFrame(columns = ['Date','Unix','Ticker','DE Ratio']).

edit:

error is due to missing )

save = gather.replace(' ','').replace(')','').replace('(','').replace('/',''+('.csv'))

Solution 2:

You imported pandas as pd. Either refer to it as such throughout, or remove the as pd from the import.

(Plus, never ever ever do except Exception... pass. You'll swallow all sorts of errors and never know what they were. If you aren't going to handle them, don't catch them at all.)


Post a Comment for "Is Pandas Not Importing? 'NameError: Global Name 'pandas' Is Not Defined'"