Skip to content

Commit 9ff4878

Browse files
committed
Deprecate positional
1 parent ab8f1c6 commit 9ff4878

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

doc/source/whatsnew/v1.4.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ Other Deprecations
602602
- Deprecated the ``prefix`` keyword argument in :func:`read_csv` and :func:`read_table`, in a future version the argument will be removed (:issue:`43396`)
603603
- Deprecated passing non boolean argument to sort in :func:`concat` (:issue:`41518`)
604604
- Deprecated passing arguments as positional for :func:`read_fwf` other than ``filepath_or_buffer`` (:issue:`41485`):
605+
- Deprecated passing arguments as positional for :func:`read_xml` other than ``path_or_buffer`` (:issue:`45133`):
605606
- Deprecated passing ``skipna=None`` for :meth:`DataFrame.mad` and :meth:`Series.mad`, pass ``skipna=True`` instead (:issue:`44580`)
606607
- Deprecated :meth:`DateOffset.apply`, use ``offset + other`` instead (:issue:`44522`)
607608
- Deprecated parameter ``names`` in :meth:`Index.copy` (:issue:`44916`)

pandas/io/xml.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
AbstractMethodError,
2020
ParserError,
2121
)
22-
from pandas.util._decorators import doc
22+
from pandas.util._decorators import (
23+
deprecate_nonkeyword_arguments,
24+
doc,
25+
)
2326

2427
from pandas.core.dtypes.common import is_list_like
2528

@@ -732,6 +735,9 @@ def _parse(
732735
return _data_to_frame(data=data_dicts, **kwargs)
733736

734737

738+
@deprecate_nonkeyword_arguments(
739+
version=None, allowed_args=["path_or_buffer"], stacklevel=2
740+
)
735741
@doc(
736742
storage_options=_shared_docs["storage_options"],
737743
decompression_options=_shared_docs["decompression_options"] % "path_or_buffer",

pandas/tests/io/xml/test_xml.py

+12
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,18 @@ def test_stylesheet_file(datapath):
769769
tm.assert_frame_equal(df_kml, df_style)
770770

771771

772+
def test_read_xml_passing_as_positional_deprecated(datapath):
773+
# GH#45133
774+
kml = datapath("io", "data", "xml", "cta_rail_lines.kml")
775+
776+
with tm.assert_produces_warning(FutureWarning, match="keyword-only"):
777+
read_xml(
778+
kml,
779+
".//k:Placemark",
780+
namespaces={"k": "http://www.opengis.net/kml/2.2"},
781+
)
782+
783+
772784
@td.skip_if_no("lxml")
773785
def test_stylesheet_file_like(datapath, mode):
774786
kml = datapath("io", "data", "xml", "cta_rail_lines.kml")

0 commit comments

Comments
 (0)