-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Add dtypes/converters arguments for pandas.read_xml #45411
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
Conversation
ParfaitG
commented
Jan 17, 2022
- closes ENH: Possible to add dtype/converters as arguments for pandas.read_xml() ? #43567
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
pandas/io/xml.py
Outdated
@@ -109,6 +130,13 @@ def __init__( | |||
elems_only: bool, | |||
attrs_only: bool, | |||
names: Sequence[str] | None, | |||
dtype: DtypeArg | None, | |||
converters: dict[str, Callable] | None, | |||
parse_dates: bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm I think we have a typing alias for this? e.g. is this what we are doing in csv parsers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did look in pandas._typing
. For read_csv
, there is no typing for converters
and parse_dates
:
def read_csv(
filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str],
...
# General Parsing Configuration
dtype: DtypeArg | None = None,
...
converters=None,
...
# Datetime Handling
parse_dates=None,
...
):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with read_excel
. Let me know how to handle typing for read_xml
. Maybe raise a TYP
issue for future PR?
def read_excel(
io,
...
dtype: DtypeArg | None = None,
...
converters=None,
...
parse_dates=False,
...
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add your alias in _typing and use it (can followup later to use it elsewhere)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small comments & pls merge master, ping on green-ish
doc/source/whatsnew/v1.5.0.rst
Outdated
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
Similar to other IO methods, :func:`pandas.read_xml` now supports assigning specific dtypes to columns, | ||
apply converter methods, and parse dates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add the issue reference here (this PR number if no issue)
doc/source/whatsnew/v1.5.0.rst
Outdated
@@ -85,6 +85,48 @@ Optional libraries below the lowest tested version may still work, but are not c | |||
|
|||
See :ref:`install.dependencies` and :ref:`install.optional_dependencies` for more. | |||
|
|||
|
|||
.. _whatsnew_140.read_xml_dtypes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to 150
pandas/io/xml.py
Outdated
@@ -109,6 +130,13 @@ def __init__( | |||
elems_only: bool, | |||
attrs_only: bool, | |||
names: Sequence[str] | None, | |||
dtype: DtypeArg | None, | |||
converters: dict[str, Callable] | None, | |||
parse_dates: bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add your alias in _typing and use it (can followup later to use it elsewhere)
thanks @ParfaitG failures unrelated |