5

我试图将导出的 opml 文件解析成 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)

这些将是我得到的错误。

回溯(最后一次调用):文件“”,第 1 行,文件“/home/pysolver33/anaconda3/envs/feedly/lib/python3.9/site-packages/pandas/core/generic.py”,第 5465 行, 在getattr 返回对象。getattribute (self, name) AttributeError: 'DataFrame' 对象没有属性 'read_xml'

df.to_xml("feedlyRSS.xml")

回溯(最后一次调用):文件“”,第 1 行,在文件“/home/pysolver33/anaconda3/envs/feedly/lib/python3.9/site-packages/pandas/init .py ”中,第 244 行getattr raise AttributeError(f"module 'pandas' has no attribute '{name}'") AttributeError: module 'pandas' has no attribute 'read_xml'

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

4

1 回答 1

5

更新pandas到最新版本。

pip install --upgrade pandas --user

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

于 2021-07-29T18:00:23.083 回答