Spyder: NameError

Created on 5 Aug 2020  路  5Comments  路  Source: spyder-ide/spyder

What steps reproduce the problem?

These commands:
import pandas
import numpy

data = pandas.read_csv("nesarc_pds.csv", low_memory=False)

print(len(data))
print(len(data.columns))

What is the expected output? What do you see instead?

Paste Traceback/Error Below (if applicable)

Produced the following response:
In [2]: print(len(data.columns))
Traceback (most recent call last):

File "", line 1, in
print(len(data.columns))

NameError: name 'data' is not defined

PASTE TRACEBACK HERE

Versions

  • Spyder version: Spyder (Python 3.7)
  • Python version:
  • Qt version:
  • PyQt version:
  • Operating System name/version:

Dependencies

PASTE DEPENDENCIES HERE
Awaiting Followup

Most helpful comment

Yes, thank you @dalthviz

All 5 comments

Hi @MMS413 how did you run your code? Seems like you are running it line by line (in which case you need to run the previous lines too in order to execute correctly that line or at least have in the namespace of your console the variable data).

For a full file run you can use the F5 shortcut or clicking the image in the toolbar.

Hope the little explanation above helps :)

Thanks, @dalthviz !

Where you able to run your code @MMS413 ?

Yes, thank you @dalthviz

Awesome closing this one then :+1:

Was this page helpful?
0 / 5 - 0 ratings