Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode from USGS website #5

Closed
tandrasfay opened this issue Oct 18, 2013 · 6 comments
Closed

Unicode from USGS website #5

tandrasfay opened this issue Oct 18, 2013 · 6 comments

Comments

@tandrasfay
Copy link

I was able to successfully read the data into python using json.loads, but after printing, the data appear to be in unicode as everything has a u' in front of it: "u'geometry': {u'type': u'Point', u'coordinates'" for example.
This leads to a problem trying to extract elements because I keep getting these types of attribute errors.
AttributeError: 'unicode' object has no attribute 'iteritems'

Has anyone else had this problem? If so, how did you work around it?

@teresita
Copy link

I've been having trouble with this too and the JSON documentation isn't very helpful, so I just did

sudo pip install --upgrade pandas

to upgrade my version of pandas to be able to use the pandas read_json function. hoping that helps.

@kqdtran
Copy link
Member

kqdtran commented Oct 19, 2013

@teresita I'm curious about how you got read_json to work? :o I've been playing around with it to no avail so far. Edit: oops, I meant read_json with the error that @reenashah mentioned in #3, not installation error.

@tandrasfay I think you can access the dictionary items without worrying about unicode. For example, if your dictionary is quakes, you can do quakes['geometry']. It seems to work for me without any unicode error, so keep us posted :-)

@GalaxyNight-day
Copy link
Member

Try

sudo apt-get install python-pandas

it worked for me

@kqdtran
Copy link
Member

kqdtran commented Oct 19, 2013

Oops, I meant the ValueError: arrays must all be same length with read_json, not installation error :D. Edited my post above.

@teresita
Copy link

@kqdtran yeah, I ran into that error too, right after posting..

I'm starting to think that a data frame isn't the best way to represent these data. Maybe there's another way to parse it to extract only the parameters that we're interested in..

@aculich
Copy link
Member

aculich commented Oct 21, 2013

The answer to everything here can be found in Issue #8 and we covered this in Office Hours, as well, so i am going to close this now.

@teresita Glad you found and shared a solution to upgrade pandas since the read_json function was missing from the version we were using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants