@@ -640,34 +640,39 @@ def json_normalize(data, record_path=None, meta=None,
640
640
path to records is ['foo', 'bar']
641
641
meta_prefix : string, default None
642
642
643
+ Returns
644
+ -------
645
+ frame : DataFrame
646
+
643
647
Examples
644
648
--------
645
- data = [{'state': 'Florida',
646
- 'shortname': 'FL',
647
- 'info': {
648
- 'governor': 'Rick Scott'
649
- },
650
- 'counties': [{'name': 'Dade', 'population': 12345},
651
- {'name': 'Broward', 'population': 40000},
652
- {'name': 'Palm Beach', 'population': 60000}]},
653
- {'state': 'Ohio',
654
- 'shortname': 'OH',
655
- 'info': {
656
- 'governor': 'John Kasich'
657
- },
658
- 'counties': [{'name': 'Summit', 'population': 1234},
659
- {'name': 'Cuyahoga', 'population': 1337}]}]
660
-
661
- result = json_normalize(data, 'counties', ['state', 'shortname',
662
- ['info', 'governor']])
663
-
664
- state governor
665
- Florida Rick Scott
666
649
650
+ >>> data = [{'state': 'Florida',
651
+ ... 'shortname': 'FL',
652
+ ... 'info': {
653
+ ... 'governor': 'Rick Scott'
654
+ ... },
655
+ ... 'counties': [{'name': 'Dade', 'population': 12345},
656
+ ... {'name': 'Broward', 'population': 40000},
657
+ ... {'name': 'Palm Beach', 'population': 60000}]},
658
+ ... {'state': 'Ohio',
659
+ ... 'shortname': 'OH',
660
+ ... 'info': {
661
+ ... 'governor': 'John Kasich'
662
+ ... },
663
+ ... 'counties': [{'name': 'Summit', 'population': 1234},
664
+ ... {'name': 'Cuyahoga', 'population': 1337}]}]
665
+ >>> from pandas.io.json import json_normalize
666
+ >>> result = json_normalize(data, 'counties', ['state', 'shortname',
667
+ ... ['info', 'governor']])
668
+ >>> result
669
+ name population info.governor state shortname
670
+ 0 Dade 12345 Rick Scott Florida FL
671
+ 1 Broward 40000 Rick Scott Florida FL
672
+ 2 Palm Beach 60000 Rick Scott Florida FL
673
+ 3 Summit 1234 John Kasich Ohio OH
674
+ 4 Cuyahoga 1337 John Kasich Ohio OH
667
675
668
- Returns
669
- -------
670
- frame : DataFrame
671
676
"""
672
677
def _pull_field (js , spec ):
673
678
result = js
0 commit comments