diff --git a/pandas/io/xml.py b/pandas/io/xml.py index bd3b515dbca2f..ac497cd266027 100644 --- a/pandas/io/xml.py +++ b/pandas/io/xml.py @@ -1058,7 +1058,7 @@ def read_xml( Examples -------- - >>> import io + >>> from io import StringIO >>> xml = ''' ... ... @@ -1078,7 +1078,7 @@ def read_xml( ... ... ''' - >>> df = pd.read_xml(io.StringIO(xml)) + >>> df = pd.read_xml(StringIO(xml)) >>> df shape degrees sides 0 square 360 4.0 @@ -1092,7 +1092,7 @@ def read_xml( ... ... ''' - >>> df = pd.read_xml(io.StringIO(xml), xpath=".//row") + >>> df = pd.read_xml(StringIO(xml), xpath=".//row") >>> df shape degrees sides 0 square 360 4.0 @@ -1118,7 +1118,7 @@ def read_xml( ... ... ''' - >>> df = pd.read_xml(io.StringIO(xml), + >>> df = pd.read_xml(StringIO(xml), ... xpath="//doc:row", ... namespaces={{"doc": "https://example.com"}}) >>> df @@ -1126,6 +1126,34 @@ def read_xml( 0 square 360 4.0 1 circle 360 NaN 2 triangle 180 3.0 + + >>> xml_data = ''' + ... + ... + ... 0 + ... 1 + ... 2.5 + ... True + ... a + ... 2019-12-31 00:00:00 + ... + ... + ... 1 + ... 4.5 + ... False + ... b + ... 2019-12-31 00:00:00 + ... + ... + ... ''' + + >>> df = pd.read_xml(StringIO(xml_data), + ... dtype_backend="numpy_nullable", + ... parse_dates=["e"]) + >>> df + index a b c d e + 0 0 1 2.5 True a 2019-12-31 + 1 1 4.5 False b 2019-12-31 """ check_dtype_backend(dtype_backend)