RAM crashed for XML to DataFrame conversion function I have created the following function which converts an XML File to a DataFrame. This function works good for files smaller than 1 GB, for anything greater than that the RAM(13GB Google Colab RAM) crashes. Same happens if I try it locally on Jupyter Notebook (4GB Laptop RAM). Is there a way to optimize the code?
Code
#Libraries
import pandas as pd
import xml.etree.cElementTree as ET

#Function to convert XML file to Pandas Dataframe    
def xml2df(file_path):

  #Parsing XML File and obtaining root
  tree = ET.parse(file_path)
  root = tree.getroot()

  dict_list = []

  for _, elem in ET.iterparse(file_path, events=(&quot;end&quot;,)):
      if elem.tag == &quot;row&quot;:
        dict_list.append(elem.attrib)      # PARSE ALL ATTRIBUTES
        elem.clear()

  df = pd.DataFrame(dict_list)
  return df

Part of an XML File ('Badges.xml')
&lt;badges&gt;
  &lt;row Id=&quot;82946&quot; UserId=&quot;3718&quot; Name=&quot;Teacher&quot; Date=&quot;2008-09-15T08:55:03.923&quot; Class=&quot;3&quot; TagBased=&quot;False&quot; /&gt;
  &lt;row Id=&quot;82947&quot; UserId=&quot;994&quot; Name=&quot;Teacher&quot; Date=&quot;2008-09-15T08:55:03.957&quot; Class=&quot;3&quot; TagBased=&quot;False&quot; /&gt;
  &lt;row Id=&quot;82949&quot; UserId=&quot;3893&quot; Name=&quot;Teacher&quot; Date=&quot;2008-09-15T08:55:03.957&quot; Class=&quot;3&quot; TagBased=&quot;False&quot; /&gt;
  &lt;row Id=&quot;82950&quot; UserId=&quot;4591&quot; Name=&quot;Teacher&quot; Date=&quot;2008-09-15T08:55:03.957&quot; Class=&quot;3&quot; TagBased=&quot;False&quot; /&gt;
  &lt;row Id=&quot;82951&quot; UserId=&quot;5196&quot; Name=&quot;Teacher&quot; Date=&quot;2008-09-15T08:55:03.957&quot; Class=&quot;3&quot; TagBased=&quot;False&quot; /&gt;
  &lt;row Id=&quot;82952&quot; UserId=&quot;2635&quot; Name=&quot;Teacher&quot; Date=&quot;2008-09-15T08:55:03.957&quot; Class=&quot;3&quot; TagBased=&quot;False&quot; /&gt;
  &lt;row Id=&quot;82953&quot; UserId=&quot;1113&quot; Name=&quot;Teacher&quot; Date=&quot;2008-09-15T08:55:03.957&quot; Class=&quot;3&quot; TagBased=&quot;False&quot; /&gt;

This conversion in needed so that I can perform furthur Data Analysis.
I have asked this on StackOverflow (Link) but the answers did not solve my query. I hope to find a solution here.
import dask
import dask.bag as db
import dask.dataframe as dd
from dask.dot import dot_graph
from dask.diagnostics import ProgressBar

dask.set_options(get=dask.multiprocessing.get)
tags_xml = db.read_text('data/Tags.xml', encoding='utf-8')
tags_xml.take(10)

Refer this link for complete tutorial Dask with XML