@@ -123,16 +123,16 @@ def json_normalize(data, record_path=None, meta=None,
123
123
Parameters
124
124
----------
125
125
data : dict or list of dicts
126
- Unserialized JSON objects.
127
- record_path : string or list of string, default None
126
+ Unserialized JSON objects
127
+ record_path : str or list of string, default None
128
128
Path in each object to list of records. If not passed, data will be
129
129
assumed to be an array of records.
130
130
meta : list of paths (string or list of strings), default None
131
131
Fields to use as metadata for each record in resulting table.
132
132
meta_prefix : string, default None
133
133
record_prefix : string, default None
134
134
If True, prefix records with dotted (?) path, e.g. foo.bar.field if
135
- path to records is ['foo', 'bar']
135
+ path to records is ['foo', 'bar'].
136
136
errors : {'raise', 'ignore'}, default 'raise'
137
137
* 'ignore' : will ignore KeyError if keys listed in meta are not
138
138
always present
@@ -148,11 +148,12 @@ def json_normalize(data, record_path=None, meta=None,
148
148
.. versionadded:: 0.20.0
149
149
150
150
max_level : integer, default None
151
- Max no of levels(depth of dict) to normalize. None, normalizes all levels.
151
+ Max no of levels(depth of dict) to normalize.
152
+ if None, normalizes all levels.
152
153
153
154
.. versionadded:: 0.24.0
154
155
155
- ignore_keys : list, keys to ignore, default 0
156
+ ignore_keys : list, keys to ignore, default []
156
157
List of keys that you do not want to normalize.
157
158
158
159
.. versionadded:: 0.24.0
@@ -177,16 +178,16 @@ def json_normalize(data, record_path=None, meta=None,
177
178
>>> from pandas.io.json import json_normalize
178
179
>>> data = [{'id': 1,
179
180
... 'name': {'first': 'Coleen', 'last': 'Volk'},
180
- ... "fitness":{"height":130, "weight":60}},
181
+ ... "fitness": {"height":130, "weight":60}},
181
182
... {'name': {'given': 'Mose', 'family': 'Regner'},
182
- ... "fitness":{"height":130, "weight":60}},
183
+ ... "fitness": {"height":130, "weight":60}},
183
184
... {'id': 2, 'name': 'Faye Raker',
184
- ... "fitness":{"height":130, "weight":60}}]
185
+ ... "fitness": {"height":130, "weight":60}}]
185
186
>>> json_normalize(data, max_level=1, ignore_keys=["name"])
186
- fitness.height fitness.weight id name
187
- 0 130 60 1.0 {'first': 'Coleen', 'last': 'Volk'}
188
- 1 130 60 NaN {'given': 'Mose', 'family': 'Regner'}
189
- 2 130 60 2.0 Faye Raker
187
+ fitness.height fitness.weight id name
188
+ 0 130 60 1.0 {'first': 'Coleen', 'last': 'Volk'}
189
+ 1 130 60 NaN {'given': 'Mose', 'family': 'Regner'}
190
+ 2 130 60 2.0 Faye Raker
190
191
191
192
>>> data = [{'state': 'Florida',
192
193
... 'shortname': 'FL',
@@ -305,10 +306,10 @@ def _recursive_extract(data, path, seen_meta, level=0):
305
306
"{err} is not always present"
306
307
.format (err = e ))
307
308
meta_vals [key ].append (meta_val )
308
-
309
309
records .extend (recs )
310
310
311
311
_recursive_extract (data , record_path , {}, level = 0 )
312
+
312
313
result = DataFrame (records )
313
314
314
315
if record_prefix is not None :
0 commit comments