Python Forum
Name Error: name 'Stockton' is not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Name Error: name 'Stockton' is not defined
#1
data = DataPortal(model=m)
    
data.load(filename="Dataframe2.xlsx", range='D2:D6', set='I')
data.load(filename="Dataframe2.xlsx", range='A2:A99', set='J')
data.load(filename="Dataframe2.xlsx", range='A1:B99', param='d', index='J')
data.load(filename="Dataframe2.xlsx", range='G1:L99', param='c', format='transposed_array')
data.load(filename="Dataframe2.xlsx", range='D1:E6' , param='b', index='I')
data.load(filename="Dataframe2.xlsx", range='N1:O6' , param='i', index='I')

data = {None: {
    'e' : {Stockton:325000, Rockwall:50000, Joliet:350000, Atlanta:450000, York:170000},
}}

m = m.create_instance(data)
m = m.create_instance(data)
After running it there is the following error code:

Quote:NameError Traceback (most recent call last)
<ipython-input-264-1e6fce871313> in <module>
9
10 data = {None: {
---> 11 'e' : {Stockton:325000, Rockwall:50000, Joliet:350000, Atlanta:450000, York:170000},
12 }}
13

NameError: name 'Stockton' is not defined

The numbers are maximum restrictions and the city names are places. If somebudy could help or give any advice I'd be grateful.
Reply
#2
As the error is saying 'Stockton' is not defined anywhere in the code shown neither is Rockwall, Joliet, Atlanta or York.
Did you mean for them to string values? add quotes to them.
data = {None: {
    'e': {'Stockton': 325000, 'Rockwall': 50000, 'Joliet': 350000,
          'Atlanta': 450000, 'York': 170000}}}
Reply
#3
Thanks, I added the marks.

However this won't solve the problem you said before that the city names are not defined, right?
Could you tell me how I should to this?
Reply
#4
It does solve the problem of NameError: name 'Stockton' is not defined
what do you want the key names to be represented as?
Note
https://docs.python.org/3/tutorial/datas...ctionaries Wrote:dictionaries are indexed by keys, which can be any immutable type; strings and numbers can always be keys. Tuples can be used as keys if they contain only strings, numbers, or tuples; if a tuple contains any mutable object either directly or indirectly, it cannot be used as a key. You can’t use lists as keys, since lists can be modified in place using index assignments, slice assignments, or methods like append() and extend().
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Getting "name 'get_weather' is not defined error and no json_data returned? trthskr4 6 337 Sep-14-2021, 09:55 AM
Last Post: trthskr4
  Error when refering to class defined in 'main' in an imported module HeRo 2 584 Apr-13-2021, 07:22 PM
Last Post: HeRo
  Why does lambda throw 'name value_o is not defined' error? karabakh 3 647 Dec-14-2020, 05:45 PM
Last Post: karabakh
  name error "name"is not defined MaartenRo 1 1,005 Jul-28-2020, 02:39 AM
Last Post: bowlofred
  python library not defined in user defined function johnEmScott 2 921 May-30-2020, 04:14 AM
Last Post: DT2000
  error ,,name append is not defined'' Killdoz 1 1,768 May-24-2020, 06:23 PM
Last Post: bowlofred
  name error:name 'clf' is not defined saiankith 3 3,761 Mar-31-2020, 06:49 PM
Last Post: jefsummers
  Error: variable can not be defined julio2000 2 1,401 Feb-09-2020, 08:51 PM
Last Post: julio2000
  Getting the error like function not defined .. suggest correct code raghava 1 867 Feb-04-2020, 11:20 PM
Last Post: micseydel
  Error name 'A' not defined RavCOder 3 1,363 Sep-23-2019, 03:51 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020