Skip to content

TYP: overload for DataFrame.to_xml #55313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ Other Deprecations
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_parquet` except ``path``. (:issue:`54229`)
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_pickle` except ``path``. (:issue:`54229`)
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_string` except ``buf``. (:issue:`54229`)
- Deprecated allowing non-keyword arguments in :meth:`DataFrame.to_xml` except ``path_or_buffer``. (:issue:`54229`)
- 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`)
- 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`)
- 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`)
Expand Down
49 changes: 49 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3272,6 +3272,55 @@ def to_html(
render_links=render_links,
)

@overload
def to_xml(
self,
path_or_buffer: None = ...,
*,
index: bool = ...,
root_name: str | None = ...,
row_name: str | None = ...,
na_rep: str | None = ...,
attr_cols: list[str] | None = ...,
elem_cols: list[str] | None = ...,
namespaces: dict[str | None, str] | None = ...,
prefix: str | None = ...,
encoding: str = ...,
xml_declaration: bool | None = ...,
pretty_print: bool | None = ...,
parser: XMLParsers | None = ...,
stylesheet: FilePath | ReadBuffer[str] | ReadBuffer[bytes] | None = ...,
compression: CompressionOptions = ...,
storage_options: StorageOptions | None = ...,
) -> str:
...

@overload
def to_xml(
self,
path_or_buffer: FilePath | WriteBuffer[bytes] | WriteBuffer[str],
*,
index: bool = ...,
root_name: str | None = ...,
row_name: str | None = ...,
na_rep: str | None = ...,
attr_cols: list[str] | None = ...,
elem_cols: list[str] | None = ...,
namespaces: dict[str | None, str] | None = ...,
prefix: str | None = ...,
encoding: str = ...,
xml_declaration: bool | None = ...,
pretty_print: bool | None = ...,
parser: XMLParsers | None = ...,
stylesheet: FilePath | ReadBuffer[str] | ReadBuffer[bytes] | None = ...,
compression: CompressionOptions = ...,
storage_options: StorageOptions | None = ...,
) -> None:
...

@deprecate_nonkeyword_arguments(
version="3.0", allowed_args=["self", "path_or_buffer"], name="to_xml"
)
@doc(
storage_options=_shared_docs["storage_options"],
compression_options=_shared_docs["compression_options"] % "path_or_buffer",
Expand Down