pandas - 属性错误 : module 'pandas' has no attribute 'read_xml' or 'to_xml'

标签 pandas xml xml-parsing opml

我试图将 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/

相关文章:

xml - 随机访问大型 XML 文件

python - PyAlgo Trade 无法读取 csv 文件

python - 对 groupby 之后的计数值创建的频率计数进行减去和除法

Java-读取xml文件

java - 将 XML 解析为 Java 对象

c - 如何使用C从Xml中获取属性值

python - 如何将2个pandas数据框中的2列彼此相乘

python - 有条件地选择和设置列值

java - 从下到上创建类实例的 XML 表示?

xml - 如何使用 XSL 在某个子节点级别添加新元素?