Skip to content

Commit 69b5d5a

Browse files
authored
TYP: overload for DataFrame.to_xml (#55313)
* TYP: overload for DataFrame.to_xml * black
1 parent 824a273 commit 69b5d5a

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

doc/source/whatsnew/v2.2.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ Other Deprecations
218218
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_parquet` except ``path``. (:issue:`54229`)
219219
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_pickle` except ``path``. (:issue:`54229`)
220220
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_string` except ``buf``. (:issue:`54229`)
221+
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_xml` except ``path_or_buffer``. (:issue:`54229`)
221222
- Deprecated automatic downcasting of object-dtype results in :meth:`Series.replace` and :meth:`DataFrame.replace`, explicitly call ``result = result.infer_objects(copy=False)`` instead. To opt in to the future version, use ``pd.set_option("future.no_silent_downcasting", True)`` (:issue:`54710`)
222223
- Deprecated downcasting behavior in :meth:`Series.where`, :meth:`DataFrame.where`, :meth:`Series.mask`, :meth:`DataFrame.mask`, :meth:`Series.clip`, :meth:`DataFrame.clip`; in a future version these will not infer object-dtype columns to non-object dtype, or all-round floats to integer dtype. Call ``result.infer_objects(copy=False)`` on the result for object inference, or explicitly cast floats to ints. To opt in to the future version, use ``pd.set_option("future.no_silent_downcasting", True)`` (:issue:`53656`)
223224
- Deprecated including the groups in computations when using :meth:`DataFrameGroupBy.apply` and :meth:`DataFrameGroupBy.resample`; pass ``include_groups=False`` to exclude the groups (:issue:`7155`)

pandas/core/frame.py

+49
Original file line numberDiff line numberDiff line change
@@ -3272,6 +3272,55 @@ def to_html(
32723272
render_links=render_links,
32733273
)
32743274

3275+
@overload
3276+
def to_xml(
3277+
self,
3278+
path_or_buffer: None = ...,
3279+
*,
3280+
index: bool = ...,
3281+
root_name: str | None = ...,
3282+
row_name: str | None = ...,
3283+
na_rep: str | None = ...,
3284+
attr_cols: list[str] | None = ...,
3285+
elem_cols: list[str] | None = ...,
3286+
namespaces: dict[str | None, str] | None = ...,
3287+
prefix: str | None = ...,
3288+
encoding: str = ...,
3289+
xml_declaration: bool | None = ...,
3290+
pretty_print: bool | None = ...,
3291+
parser: XMLParsers | None = ...,
3292+
stylesheet: FilePath | ReadBuffer[str] | ReadBuffer[bytes] | None = ...,
3293+
compression: CompressionOptions = ...,
3294+
storage_options: StorageOptions | None = ...,
3295+
) -> str:
3296+
...
3297+
3298+
@overload
3299+
def to_xml(
3300+
self,
3301+
path_or_buffer: FilePath | WriteBuffer[bytes] | WriteBuffer[str],
3302+
*,
3303+
index: bool = ...,
3304+
root_name: str | None = ...,
3305+
row_name: str | None = ...,
3306+
na_rep: str | None = ...,
3307+
attr_cols: list[str] | None = ...,
3308+
elem_cols: list[str] | None = ...,
3309+
namespaces: dict[str | None, str] | None = ...,
3310+
prefix: str | None = ...,
3311+
encoding: str = ...,
3312+
xml_declaration: bool | None = ...,
3313+
pretty_print: bool | None = ...,
3314+
parser: XMLParsers | None = ...,
3315+
stylesheet: FilePath | ReadBuffer[str] | ReadBuffer[bytes] | None = ...,
3316+
compression: CompressionOptions = ...,
3317+
storage_options: StorageOptions | None = ...,
3318+
) -> None:
3319+
...
3320+
3321+
@deprecate_nonkeyword_arguments(
3322+
version="3.0", allowed_args=["self", "path_or_buffer"], name="to_xml"
3323+
)
32753324
@doc(
32763325
storage_options=_shared_docs["storage_options"],
32773326
compression_options=_shared_docs["compression_options"] % "path_or_buffer",

0 commit comments

Comments
 (0)