@@ -238,15 +238,16 @@ def test_non_ascii_key(self):
238
238
tm .assert_frame_equal (result , expected )
239
239
240
240
def test_missing_field (self , author_missing_data ):
241
- # GH20030: Checks for robustness of json_normalize - should
242
- # unnest records where only the first record has a None value
241
+ # GH21356
243
242
result = json_normalize (author_missing_data )
244
243
ex_data = [
245
- {'author_name.first' : np .nan ,
244
+ {'info' : np .nan ,
245
+ 'author_name.first' : np .nan ,
246
246
'author_name.last_name' : np .nan ,
247
247
'info.created_at' : np .nan ,
248
248
'info.last_updated' : np .nan },
249
- {'author_name.first' : 'Jane' ,
249
+ {'info' : None ,
250
+ 'author_name.first' : 'Jane' ,
250
251
'author_name.last_name' : 'Doe' ,
251
252
'info.created_at' : '11/08/1993' ,
252
253
'info.last_updated' : '26/05/2012' }
@@ -351,7 +352,7 @@ def test_json_normalize_errors(self):
351
352
errors = 'raise'
352
353
)
353
354
354
- def test_nonetype_dropping (self ):
355
+ def test_nonetype (self ):
355
356
# GH20030: Checks that None values are dropped in nested_to_record
356
357
# to prevent additional columns of nans when passed to DataFrame
357
358
data = [
@@ -367,7 +368,8 @@ def test_nonetype_dropping(self):
367
368
]
368
369
result = nested_to_record (data )
369
370
expected = [
370
- {'author_name.first' : 'Smith' ,
371
+ {'info' : None ,
372
+ 'author_name.first' : 'Smith' ,
371
373
'author_name.last_name' : 'Appleseed' },
372
374
{'author_name.first' : 'Jane' ,
373
375
'author_name.last_name' : 'Doe' ,
@@ -395,6 +397,7 @@ def test_nonetype_top_level_bottom_level(self):
395
397
}
396
398
result = nested_to_record (data )
397
399
expected = {
400
+ 'id' : None ,
398
401
'location.country.state.id' : None ,
399
402
'location.country.state.town.info.id' : None ,
400
403
'location.country.state.town.info.region' : None ,
@@ -423,6 +426,7 @@ def test_nonetype_multiple_levels(self):
423
426
}
424
427
result = nested_to_record (data )
425
428
expected = {
429
+ 'id' : None ,
426
430
'location.id' : None ,
427
431
'location.country.id' : None ,
428
432
'location.country.state.id' : None ,
0 commit comments