I have a xml file like:
<plays format="tokens">
    <period number="1">
      <play/>
      <play/>
      <play/>
    </period>
    <period number="2">
      <play/>
      <play/>
      <play/>
    </period>
Each play tag contains a bunch of variables, but I would also like to add the period number as a variable to the play tags. My goal is to produce a table with each play and their attributes as well as a column that says which period that played occurred in (1 or 2).
My current code to flatten the plays out is:
d = []
for play in root.iter('play'):
    d.append(play.attrib)
    
df = pd.DataFrame(d)
This gives me every play and their attributes in the table df, but the period is not currently included in this table. Any direction would help, thank you!
 
    