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 |
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xml_to_df-0.0.6.tar.gz
(2.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xml_to_df-0.0.6.tar.gz.
File metadata
- Download URL: xml_to_df-0.0.6.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
226879c8ab85d10aca1cf1423e426f7279fbdb729c3b1743fba7165d8522be67
|
|
| MD5 |
c0ab3d17439b60a21f701fb737243923
|
|
| BLAKE2b-256 |
89dcdc20385db5dba15b1b7858e352e0a8221f2327934baa6721260bfe0c4fde
|
File details
Details for the file xml_to_df-0.0.6-py3-none-any.whl.
File metadata
- Download URL: xml_to_df-0.0.6-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b079bca6ef42d3e5d2606c8f5494648011fdea1419b5dd91bcd0b671b98f329c
|
|
| MD5 |
a3151640a50a7abb70854ca36b56c02f
|
|
| BLAKE2b-256 |
ffe4dfecaafb54cb8a0c27e73bad8a9912c0318976e5ddad02bf8d0e1bf6e52c
|