Install & Compatibility
Where this runs
tested against v0.3.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 1.702s · 344.6MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 10.2s · import 1.596s · 313MB
330MB installed
● package 330MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
read_xml
✓ from pandas_read_xml import read_xml
✗ import pandas_read_xml as pdx
auto_flatten
✓ from pandas_read_xml import auto_flatten
flatten
✓ from pandas_read_xml import flatten
Reads a simple XML string or file path into a pandas DataFrame. The second argument specifies the 'root key list' to navigate to the desired data elements.
import pandas_read_xml as pdx
import io
xml_data = """<?xml version='1.0' encoding='utf-8'?>
<root>
<item id="1">
<name>Apple</name>
<price>1.00</price>
</item>
<item id="2">
<name>Banana</name>
<price>0.50</price>
</item>
</root>"""
# To read from a file, replace io.StringIO(xml_data) with 'path/to/your/file.xml'
df = pdx.read_xml(io.StringIO(xml_data), ['root', 'item'])
print(df)
Debug
Known issues
breakingThe functionality of this library has been incorporated into the main `pandas` library itself as `pandas.read_xml()` since `pandas` version 1.3.0. For new projects or installations with pandas >= 1.3.0, it is generally recommended to use `pd.read_xml()` directly instead of this standalone package.fixIf using pandas >= 1.3.0, replace `import pandas_read_xml as pdx` and `pdx.read_xml(...)` with `import pandas as pd` and `pd.read_xml(...)`.
affects: <1.3.0 (for pandas core), all versions (for this standalone lib)
deprecatedThe `pandas-read-xml` GitHub repository explicitly states: 'Note that this isn't a mature or anything close to a complete solution. So I don't recommend using it in "production".' This suggests it was intended as a temporary solution before native pandas support.fixPrefer `pandas.read_xml` for robust and actively maintained solutions, especially in production environments.
affects: All versions of `pandas-read-xml`
gotchaWorking with complex or deeply nested XML structures can be challenging. Both `pandas-read-xml` and `pandas.read_xml` might require careful use of XPath expressions, handling of XML namespaces, and potentially pre-processing with XSLT to flatten data.fixThoroughly understand your XML schema. Utilize the `xpath`, `namespaces`, and `stylesheet` parameters (in `pandas.read_xml`) or `root_key_list` (in `pandas-read-xml`) to target specific elements. Consider using `lxml` as the parser for advanced XPath capabilities.
affects: All versions
gotchaThe `root_is_rows` and `transpose` arguments in `pandas-read-xml` (and similar logic in `pandas.read_xml`'s `xpath` and structure interpretation) can be tricky. Incorrect usage might lead to a transposed DataFrame or incorrect row/column interpretation if the XML structure doesn't align with the default assumptions.fixExperiment with `root_is_rows=False` and `transpose=True` if your initial DataFrame output appears malformed or inverted. Carefully inspect the resulting DataFrame and adjust parameters based on your XML's structure.
affects: All versions
gotchaXML data can sometimes have mixed types within the same tags (e.g., some instances are single elements, others are lists), making flattening difficult. `pandas_read_xml` includes `flatten()` and `auto_flatten()` methods to address this, but it remains a complex issue.fixUtilize the `flatten()` or `auto_flatten()` methods provided by `pandas_read_xml` if encountering inconsistent tag structures. For `pandas.read_xml`, manual post-processing with `json_normalize` (after converting to dict) or `explode` might be necessary.
affects: All versions
Upgrade
Version history
0.3.1latest on PyPI · released Apr 8, 2021
Audit
Dependencies
pandasrequiredCore data structure for output.
xmltodictrequiredUsed internally for XML parsing.
lxmloptionalRecommended for more complex XPath expressions when using the underlying pandas.read_xml or for performance, though not a direct dependency of pandas-read-xml itself.