pandasxmlxml-parsingopml

AttributeError: module 'pandas' has no attribute 'read_xml' or 'to_xml'


Im trying to parse feedly RSS feeds exported opml files into xml files.

I succeeded into doing so with my use of listparser, dicttoxml, and pandas. I wanted to try out pandas read_xml() and to_xml() to find out how it would perform compared to me parsing the opml to xml myself.

import pandas as pd
my_opml = './feedly-e42affb2-52f5-4889-8901-992e3a3e35de-2021-06-28.opml'
df = pd.read_xml(my_opml)

these would be the error that i get.

Traceback (most recent call last): File "", line 1, in File "/home/pysolver33/anaconda3/envs/feedly/lib/python3.9/site-packages/pandas/core/generic.py", line 5465, in getattr return object.getattribute(self, name) AttributeError: 'DataFrame' object has no attribute 'read_xml'

df.to_xml("feedlyRSS.xml")

Traceback (most recent call last): File "", line 1, in File "/home/pysolver33/anaconda3/envs/feedly/lib/python3.9/site-packages/pandas/init.py", line 244, in getattr raise AttributeError(f"module 'pandas' has no attribute '{name}'") AttributeError: module 'pandas' has no attribute 'read_xml'

My pandas version is 1.2.5. I checked pip and 1.2.5 should be the latest version. Is there a particular reason why i can't play with read_xml or to_xml?


Solution

  • Update pandas to the newest version.

    pip install --upgrade pandas --user

    pd.read_xml('file.xml') is available in version 1.3.0.