Skip to main content

XML to Pandas Dataframe

Flattens out nested xml to individual columns in dataframe

Sample input.xml
<bookstore>
<book category="COOKING">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
    <values>
      <value id="300">1</value>
      <value id="100">5</value>
      <value id="200">2</value>
    </values>
  </book>
  <book category="CHILDREN">
    <title lang="en" language="hello">Harry Potter</title>
    <author>J K. Rowling</author>
    <cricketers>
        <cricketer1>Praveen</cricketer1>
        <cricketer2>Pathan</cricketer2>
        <country>india</country>
        <country>india1</country>
      </cricketers>
    <year>2005</year>
    <price>29.99</price>
    <values>
      <value></value>
      <value></value>
    </values>
  </book>
  <book category="WEB">
    <title lang="en">Learning XML</title>
    <author>Erik T. Ray</author>
    <year>2003</year>
    <price>39.95</price>
  </book>
</bookstore>

df = xml_to_df.convert_xml_to_df("input.xml")

df.head()

Output dataframe
book_category book_title_lang book_title book_author book_year book_price book_values_value_id book_values_value book_title_language book_cricketers_cricketer1 book_cricketers_cricketer2 book_cricketers_country
COOKING en Everyday Italian Giada De Laurentiis 2005 30.00 [300, 100, 200] [1, 5, 2] NaN NaN NaN NaN
CHILDREN en Harry Potter J K. Rowling 2005 29.99 NaN NaN hello Praveen Pathan [india, india1]
WEB en Learning XML Erik T. Ray 2003 39.95 NaN NaN NaN NaN NaN NaN

Metadata

Release files for xml-to-df 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xml-to-df 0.0.6
File Size Uploaded Provenance Actions
xml_to_df-0.0.6.tar.gz 2.6 kB Without provenance Details for xml_to_df-0.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xml-to-df 0.0.6
File Interpreter ABI Platform Actions
xml_to_df-0.0.6-py3-none-any.whl Python 3 none any Details for xml_to_df-0.0.6-py3-none-any.whl

Total release size: 6.1 kB

Release files / xml_to_df-0.0.6.tar.gz

Download URL xml_to_df-0.0.6.tar.gz
Size 2.6 kB
Tags Source
SHA-256 checksum
How to use checksums
226879c8ab85d10aca1cf1423e426f7279fbdb729c3b1743fba7165d8522be67
BLAKE2b-256 checksum
How to use checksums
89dcdc20385db5dba15b1b7858e352e0a8221f2327934baa6721260bfe0c4fde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release files / xml_to_df-0.0.6-py3-none-any.whl

Download URL xml_to_df-0.0.6-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b079bca6ef42d3e5d2606c8f5494648011fdea1419b5dd91bcd0b671b98f329c
BLAKE2b-256 checksum
How to use checksums
ffe4dfecaafb54cb8a0c27e73bad8a9912c0318976e5ddad02bf8d0e1bf6e52c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Security for xml-to-df 0.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page