title: Parse big xml files in python 3
body: <p>I'm new to python and I am looking for a fast implementation to parse big xml file (~0.5-1 G) with the following template:</p>
  
  <pre><code>&lt;timestep time="2.00"&gt;
      &lt;vehicle id="carflow.0" x="-9897.274589" y="-8.250000" speed="49.840822" lane="section1_0" /&gt;
      .... (more vehicles)
  &lt;/timestep&gt;
  ... (more timesteps)
  </code></pre>
  
  <p>I'm willing to parse it to DataFrame. 
  My code is (ET is lxml.etree):</p>
  
  <pre><code>def parseXML(filename):
     df = pd.DataFrame()
     old_time = 0.0
     time = 0.0
     events = ("end","start")
     tree = ET.iterparse(filename, events=events)
     for event, elem in tree:
        if elem.tag == "timestep" and event =="start":
            time = float(elem.attrib.get('time'))
        elif elem.tag == "timestep" and event =="end":
            elem.clear()
        elif elem.tag == 'vehicle' and event=="end":
            id = int(elem.attrib.get('id').split('.')[1])
            x = float(elem.attrib.get('x'))
            y = float(elem.attrib.get('y'))
            speed = float(elem.attrib.get('speed'))
            lane = int(elem.attrib.get('lane').split('_')[1])
            data = pd.DataFrame([time, id, x, y, speed, lane]).T
            elem.clear()
            df = df.append(data)
        if time%50 == 0 and time!=old_time:
            old_time = time
            print(time)
     df.columns = ['time','id','x','y','speed','lane']      
     return df
  </code></pre>
  
  <p>Is there a way to improve my code?</p>