Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7608403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:54:15+00:00 2026-05-31T00:54:15+00:00

I have a Python dictionary that I generated from an arcgis shapefile. The dictionary

  • 0

I have a Python dictionary that I generated from an arcgis shapefile. The dictionary has key = FID (point ID) : value = either nothing or “HH”. The dictionary looks like this:

Cluster_dict = {0: [u' '], 1: [u'HH'], 2: [u'HH'], 3: [u' '], 4: [u' '], 5: [u' '], 6: [u' '], 7: [u' '], 8: [u' '], 9: [u' '], 10: [u' '], 11: [u'HH'], 12: [u'HH'], 13: [u'HH'], 14: [u'HH'], 15: [u' '], 16: [u' '], 17: [u' '], 18: [u' '], 19: [u' '], 20: [u' '], 21: [u' '], 22: [u' '], 23: [u'HH'], 24: [u'HH'], 25: [u' '], 26: [u' '], 27: [u' '], 28: [u' ']....}

The extra characters of the value [u’ ‘] and [u’HH’] show up after I created the dictionary from the arcgis shapefile with the following code:

arcpy.ClustersOutliers_stats('input_file', "GRID_CODE", 'output_file',  "INVERSE_DISTANCE", "EUCLIDEAN_DISTANCE", "NONE", "", "")
Cluster_dict = {}
sc = arcpy.SearchCursor('output_file')
for row in sc:
    Cluster_dict[row.FID] = [row.COType]

print Cluster_dict

I’m trying to use this dictionary to append to a nested list of each point’s 8 (or less) neighbors using the following code:

clusterList = []
for clist in Neighbors_List:
    row = []
    for ccode in clist:
        row.append(Cluster_dict[ccode])
    clusterList.append(row)
 print clusterList

But when it gets to row.append(Cluster_dict[ccode]), I get a key error ‘0’. I’m thinking this is because there is no value for key 0, but I’m not sure about this. When I used the following code to replace all the [u’ ‘] with “None”, the dictionary doesn’t replace the empty values. I’m using the following code to try and replace [u’ ‘].

for k, v in Cluster_dict.iteritems():
    if v is [u' ']:       #I've also tried '[u' ']'
        Cluster_dict[k] = 'None'

print Cluster_dict 

Any help would be appreciated. Would it be easier to strip [u’ ‘] out of all the values in the dictionary? If so, can someone show me how to strip unwanted characters out of a dictionary?

Thanks very much for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:54:16+00:00Added an answer on May 31, 2026 at 12:54 am

    It doesn’t do what you want, use == instead.

    Also, dict.get()

    Also, ‘0’ does not equal 0

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a python dictionary object that contains a boolean for every key, e.g.:
I have a Python dictionary that labels key name to attributes. The program that
I have data in a python dictionary that I'd like to store in a
I have a python function that randomize a dictionary representing a position specific scoring
I have a python module that makes use of a huge dictionary global variable,
If I have a list(or array, dictionary....) in python that could exceed the available
When using Python is it possible that a dict can have a value that
I have a python dictionary e.g.: [{pk:1,name:John,size:1/4 },{},{},etc] That size is 1/4 inch,how would
I have a method in c++ that gets called from python and needs to
Really two questions: If I have a dictionary (that originally came from parsing a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.