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

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

我正在尝试将 feedly RSS 提要解析为 xml 个文件。

我通过使用 listparser、dicttoxml 和 pandas 成功做到了这一点。我想尝试 pandas read_xml() 和 to_xml() 以了解与我自己将 opml 解析为 xml 相比它的性能如何。

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

这些就是我得到的错误。

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'

我的 pandas 版本是 1.2.5。我检查了pip,1.2.5应该是最新版本。我不能玩 read_xml 或 to_xml 有什么特别的原因吗?

更新 pandas 到最新版本。

pip install --upgrade pandas --user

pd.read_xml('file.xml') 在版本 1.3.0 中可用。