pandas.io.json.json_normalize with very nested json

In the pandas example (below) what do the brackets mean? Is there a logic to be followed to go deeper with the []. […] result = json_normalize(data, ‘counties’, [‘state’, ‘shortname’, [‘info’, ‘governor’]]) Each string or list of strings in the [‘state’, ‘shortname’, [‘info’, ‘governor’]] value is a path to an element to include, in addition … Read more

How can I normalize a URL in python

Have a look at this module: werkzeug.utils. (now in werkzeug.urls) The function you are looking for is called “url_fix” and works like this: >>> from werkzeug.urls import url_fix >>> url_fix(u’http://de.wikipedia.org/wiki/Elf (Begriffsklärung)’) ‘http://de.wikipedia.org/wiki/Elf%20%28Begriffskl%C3%A4rung%29′ It’s implemented in Werkzeug as follows: import urllib import urlparse def url_fix(s, charset=”utf-8″): “””Sometimes you get an URL by a user that just … Read more

Inverse of Pandas json_normalize

I implemented it with a couple functions def set_for_keys(my_dict, key_arr, val): “”” Set val at path in my_dict defined by the string (or serializable object) array key_arr “”” current = my_dict for i in range(len(key_arr)): key = key_arr[i] if key not in current: if i==len(key_arr)-1: current[key] = val else: current[key] = {} else: if type(current[key]) … Read more