-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: to_xml
with index=False
and offset input index
#42464
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,10 @@ | |
|
||
import pandas.util._test_decorators as td | ||
|
||
from pandas import DataFrame | ||
from pandas import ( | ||
DataFrame, | ||
RangeIndex, | ||
) | ||
import pandas._testing as tm | ||
|
||
from pandas.io.common import get_handle | ||
|
@@ -290,6 +293,42 @@ def test_index_false_rename_row_root(datapath, parser): | |
assert output == expected | ||
|
||
|
||
def test_index_false_with_offset_input_index(parser): | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure we annotate reason for test even on bug fixes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can remove the docstring if it goes against coding guidelines for the project. But personally I like to give context to tests like these. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we normally don't add this, just a comment to the issue. but no harm as you have written it. |
||
Tests that the output does not contain the `<index>` field when the index of the | ||
input Dataframe has an offset. | ||
|
||
This is a regression test for issue #42458. | ||
""" | ||
|
||
expected = """\ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<data> | ||
<row> | ||
<shape>square</shape> | ||
<degrees>360</degrees> | ||
<sides>4.0</sides> | ||
</row> | ||
<row> | ||
<shape>circle</shape> | ||
<degrees>360</degrees> | ||
<sides/> | ||
</row> | ||
<row> | ||
<shape>triangle</shape> | ||
<degrees>180</degrees> | ||
<sides>3.0</sides> | ||
</row> | ||
</data>""" | ||
|
||
offset_geom_df = geom_df.copy() | ||
offset_geom_df.index = RangeIndex(start=10, stop=13, step=1) | ||
stephan-hesselmann-by marked this conversation as resolved.
Show resolved
Hide resolved
|
||
output = offset_geom_df.to_xml(index=False, parser=parser) | ||
output = equalize_decl(output) | ||
|
||
assert output == expected | ||
|
||
|
||
# NA_REP | ||
|
||
na_expected = """\ | ||
|
Uh oh!
There was an error while loading. Please reload this page.