Fill pandas dataframe with specific values from json
<p>I have a very large, deeply nested json, from which I need only some key-values pairs, not all of them. Because it's very deeply nested, it's not comfortable to create a pandas dataframe directly from the json, because all the values I need will not be in columns.</p>

<p>I need to create pandas dataframe that should look like:</p>

<pre><code>Groupe      Id   MotherName   FatherName
Advanced    56   Laure         James
Middle      11   Ann           Nicolas
Advanced    6    Helen         Franc
</code></pre>

<p>From my complex json I extract the values I need as follows (All the values are extracted correctly so there is no error here):</p>

<pre><code>jfile=json.loads(data)
groupe=jfile['location']['groupe']
id=jfile['id']
MotherName=jfile['Mother']['MotherName']
FatherName=jfile['Father']['FatherName']
</code></pre>

<p>jfile looks like:</p>

<p><code>{"location":{"town":"Rome","groupe":"Advanced",
"school":{"SchoolGroupe":"TrowMet", "SchoolName":"VeronM"}},
"id":"145",
"Mother":{"MotherName":"Helen","MotherAge":"46"},"NGlobalNote":2,
"Father":{"FatherName":"Peter","FatherAge":"51"},
"Teacher":["MrCrock","MrDaniel"],"Field":"Marketing","season":["summer","spring"]}</code></p>

<p>Then I create an empty dataframe and try to fill it with these values:</p>

<pre><code>df=pd.DataFrame(columns=['group', 'id', 'Father', 'Mother'])
for index,row in df.iterrows():
    row['groupe']=jfile['location']['groupe']
    row['id']=jfile['id']
    row['MotherName']=jfile['Father']['FatherName']
    row['id']=jfile['Mother']['MotherName']
</code></pre>

<p>but when I try to print it, it says the dataframe is empty:</p>

<blockquote>
  <p>Empty DataFrame Columns: [groupe, id, MotherName, FatherName] Index:
  []</p>
</blockquote>

<p>Why is it empty with this method, and how I can fill it properly?</p>