-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: XlsxWriter ignoring formats on numpy types if merged cells #27006
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 all commits
1809233
4d5eab1
91c0bfe
a73332c
b096dea
225a8da
fd7da92
8087f07
ddde35e
b16397d
9293641
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 |
---|---|---|
|
@@ -1162,6 +1162,22 @@ def test_path_local_path(self, engine, ext): | |
path="foo.{ext}".format(ext=ext)) | ||
tm.assert_frame_equal(result, df) | ||
|
||
def test_merged_cell_custom_objects(self, engine, merge_cells, ext): | ||
# see GH-27006 | ||
mi = MultiIndex.from_tuples([(pd.Period('2018'), pd.Period('2018Q1')), | ||
(pd.Period('2018'), pd.Period('2018Q2'))]) | ||
expected = DataFrame(np.ones((2, 2)), columns=mi) | ||
expected.to_excel(self.path) | ||
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. Once you add the 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. So if I do this, won't this always fail the assert comparison? When this is False, it creates a single cell that contains both levels in the excel file (for instance '2018.2018Q2'). When I read this back in, it's read in as a single column Index and fails comparing against the original MultiIndex. |
||
result = pd.read_excel(self.path, header=[0, 1], | ||
index_col=0, convert_float=False) | ||
# need to convert PeriodIndexes to standard Indexes for assert equal | ||
expected.columns.set_levels([[str(i) for i in mi.levels[0]], | ||
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. Can just simplify this as 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. Simplify this as stated 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. This simplication doesn't seem to work. Comparison fails - the Index read back in isn't preserved as a Period.
|
||
[str(i) for i in mi.levels[1]]], | ||
level=[0, 1], | ||
inplace=True) | ||
expected.index = expected.index.astype(np.float64) | ||
tm.assert_frame_equal(expected, result) | ||
|
||
|
||
class TestExcelWriterEngineTests: | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.