pandas导出数据df.to_xml() XML
import numpy as npimport pandas as pddf.to_xml() # 输出 xml 字符# 指定根节点和各行的标签名称df.to_xml(root_name="geometry", row_name="objects")# 编写以属性为中心(attribute-centric)的XMLdf.to_xml(attr_cols=df.columns.tolist())# <row index="0" name="Liver" team="E" Q1="89" Q2="21" Q3="24" Q4="64"/># 编写元素和属性的组合(df.to_xml( index=False, attr_cols=['shape'], elem_cols=['degrees', 'sides']))# 具有默认命名空间的 XMLdf.to_xml(namespaces={"": "https://example.com"})# 具有命名空间前缀的 XMLdf.to_xml(namespaces={"doc": "https://example.com"}, prefix="doc")# 编写不带声明或漂亮打印的XMLdf.to_xml(xml_declaration=False, pretty_print=False)# XML和样式表转换,xsl 为样式字符串df.to_xml(stylesheet=xsl)