Skip to content

Commit 3c94206

Browse files
author
dickreuter
committed
shortened lines to pass linting
1 parent 2028924 commit 3c94206

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

doc/source/whatsnew/v0.20.0.txt

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ users upgrade to this version.
99

1010
Highlights include:
1111

12-
- Building pandas for development now requires ``cython >= 0.23`` (:issue:`14831`)
1312

1413
Check the :ref:`API Changes <whatsnew_0200.api_breaking>` and :ref:`deprecations <whatsnew_0200.deprecations>` before updating.
1514

@@ -61,7 +60,6 @@ Other enhancements
6160
- The ``usecols`` argument in ``pd.read_csv`` now accepts a callable function as a value (:issue:`14154`)
6261
- ``pd.DataFrame.plot`` now prints a title above each subplot if ``suplots=True`` and ``title`` is a list of strings (:issue:`14753`)
6362
- ``pd.Series.interpolate`` now supports timedelta as an index type with ``method='time'`` (:issue:`6424`)
64-
- ``pandas.io.json.json_normalize`` If meta keys are not always present a new option to set errors="ignore" (:issue:`14583`)
6563
- ``pandas.io.json.json_normalize`` gained the option ``errors='ignore'|raise``; the default is raise and is backward compatible. (:issue:`14583`)
6664

6765

pandas/io/json.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,12 @@ def json_normalize(data, record_path=None, meta=None,
743743
path to records is ['foo', 'bar']
744744
meta_prefix : string, default None
745745
error: {'raise', 'ignore'}, default 'raise'
746-
* ignore: will ignore KeyError if keys listed in meta are not always present
747-
* raise: will raise KeyError if keys listed in meta are not always present
746+
* ignore: will ignore KeyError if keys listed in meta are not
747+
always present
748+
* raise: will raise KeyError if keys listed in meta are not
749+
always present
750+
751+
.. versionadded:: 0.20.0
748752
749753
Returns
750754
-------
@@ -850,7 +854,8 @@ def _recursive_extract(data, path, seen_meta, level=0):
850854
if errors == 'ignore':
851855
meta_val = np.nan
852856
else:
853-
raise KeyError("Try running with errors='ignore' as key %s is not always present.", e)
857+
raise KeyError("Try running with errors='ignore'"
858+
"as key %s is not always present.", e)
854859
meta_vals[key].append(meta_val)
855860

856861
records.extend(recs)

pandas/io/tests/json/test_json_norm.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ def test_nested_flattens(self):
227227

228228

229229
def test_json_normalize_errors(self):
230-
# GH14583: If meta keys are not always present a new option to set errors='ignore' has been implemented
230+
# GH14583: If meta keys are not always present
231+
# a new option to set errors='ignore' has been implemented
231232
i = {
232233
"Trades": [{
233234
"general": {
@@ -238,38 +239,33 @@ def test_json_normalize_errors(self):
238239
"symbol": "AAPL",
239240
"name": "Apple",
240241
"price": "0"
241-
242242
}, {
243-
244243
"symbol": "GOOG",
245244
"name": "Google",
246245
"price": "0"
247-
248246
}
249247
]
250248
}
251249
}, {
252250
"general": {
253251
"tradeid": 100,
254252
"stocks": [{
255-
256253
"symbol": "AAPL",
257254
"name": "Apple",
258255
"price": "0"
259-
260256
}, {
261257
"symbol": "GOOG",
262258
"name": "Google",
263259
"price": "0"
264-
265260
}
266261
]
267262
}
268263
}
269264
]
270265
}
271266
j = json_normalize(data=i['Trades'], record_path=[['general', 'stocks']],
272-
meta=[['general', 'tradeid'], ['general', 'trade_version']], errors='ignore')
267+
meta=[['general', 'tradeid'], ['general', 'trade_version']],
268+
errors='ignore')
273269
expected={'general.trade_version': {0: 1.0, 1: 1.0, 2: '', 3: ''},
274270
'general.tradeid': {0: 100, 1: 100, 2: 100, 3: 100},
275271
'name': {0: 'Apple', 1: 'Google', 2: 'Apple', 3: 'Google'},
@@ -280,7 +276,8 @@ def test_json_normalize_errors(self):
280276

281277
self.assertRaises(KeyError,
282278
json_normalize, data=i['Trades'], record_path=[['general', 'stocks']],
283-
meta=[['general', 'tradeid'], ['general', 'trade_version']], errors='raise'
279+
meta=[['general', 'tradeid'], ['general', 'trade_version']],
280+
errors='raise'
284281
)
285282

286283

0 commit comments

Comments
 (0)