COMPAT: Allow multi-indexes to be written to excel
State: closed

(Even though they cannot be read back in)

Closes #10564


Labels:
name: IO Excel
description: read_excel, to_excel
name: MultiIndex
name: Compat
description: pandas objects compatability with Numpy or Python functions

Comments:
Is this `warn_roundtrip_serialization` keyword needed?

I agree it can be annoying to not be able to remove a warning, but a keyword just for this that maybe is not needed anymore in a next release seems also a bit unnecessary

another way to do this is to make a custom warning class (e.g. inherit from `UserWarning`). Then always show the warning. If the users don't like it they can always filter. I DO think this is important to always warn as you are doing something which is not reversible.

It is maybe not reversible with a simple `read_excel`, but it is possible to get the same as original with a little bit of processing.

BTW, the docstring of `read_excel` is not fully correct, as it supports creating a multi-index index with `index_col` (it just can't deal with the formatting of multi-indices by `to_excel`)

And, @jreback, I like the idea of having a global way to turn of this kind of UserWarnings more than special keywords all over the place (and if we want an argument for it, I would rather go with something more general, like `silent` or `verbose`)

@jorisvandenbossche 

hmm, ok could have `io.excel.warnings='verbose'` (for an option).

Though maybe a more general `io.warnings='verbose'`

Is this still being considered?

can you rebase / squash?

@jorisvandenbossche what do you think about `verbose`

Yeah, I'll see if I can pull in the master and squash.  

Sorry I'm bungling this at the moment.

Ok.  Got my git figured out.  Hopefully tests will still pass. Thanks.

In any case, I think  `verbose` is much better as the original name. 
I think I also like that you can set an option for such things, but maybe both approaches do not exclude each other for now? 

Ok.  Couldn't figure out what to do with the verbose keyword, so I improvised and copied someone else's custom warning.

you need to still accept the `verbose` kw in `DataFrame.to_excel` and pass in thru as another parameter. Then reference it in the formatter; further a custom warning is fine (though emitting it should still be controlled by `verbose` as before)

Now other things are breaking and I don't really see why. I'm just about at the end of my rope here.
So now there's a verbose keyword to ExcelFormatter too?

just pass it thru, you had added it before; just put it back in `to_excel` (and then to `ExcelFormatter`).

I'm not sure what the tests were trying to catch before or if they're good, but I can make them pass by reordering the tests for valid input before testing for aliases.  (seems kinda sketchy)

Don't think this was my fault:  https://travis-ci.org/pydata/pandas/jobs/75683428, it passed on the branch https://travis-ci.org/flamingbear/pandas/builds/75683397

I just pushed a no-op branch up again.   Is there a way I could have scheduled travis tests without pushing the branch again?

@jreback I think this is ready for you now.  Thanks. Matt

lgtm. @jorisvandenbossche ?

@jreback @jorisvandenbossche : Can you give me some help here?  This happened before and I repushed and it fixed itself.  I don't know what a ResourceError is,  https://travis-ci.org/pydata/pandas/jobs/75848253, but it's still passing fine on my travis.  I can keep pushing until it goes through again.  Is that the best option? This happened before https://github.com/pydata/pandas/pull/10570#issuecomment-131395891

just leave for now
I think this is caused by something else

alright if this one fails, I'll leave it.  Thanks

@flamingbear minor change, then lgtm. ping when green.

@jreback we're green.  Thanks.

@jorisvandenbossche ?

Looks good! Thanks!

Thanks guys.