我试图将 feedly RSS feeds 导出的 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)
这些将是我得到的错误。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 版本中可用
关于pandas - 属性错误 : module 'pandas' has no attribute 'read_xml' or 'to_xml' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68166626/