When exporting to Excel, it is possible to add multiple number formats and then use set_column
to apply any desired numeric format to any column. Attempting to do the same for date or date-time columns has no effect however.
It is possible to set a format for all date columns or all date-time columns using the date_format
and datetime_format
arguments to ExcelWriter()
, but that applies a single format to all dates and a single format to all date-time values.
In my particular case, I have a column that is intended to represent a whole month, and I want to format it as such in the exported data, and I have other date columns that represent specific dates. There is apparently no way to accomplish that. Why?
Why not simply allow applying date formats to columns just as one can apply numeric formats to columns?
Comment From: stevecj
Suggested pattern:
Pass False
as the value to date_format
and/or datetime_format
to indicate that the formats for columns of those types should not be set automatically.
Comment From: WillAyd
I think this would be a logical enhancement - interested in submitting a pull request @stevecj ?
Comment From: stevecj
I haven't worked on Pandas source before, but I'll certainly give it a shot.
Comment From: stevecj
Short on time. Still plan to try making this enhancement at some point if nobody beats me to it.
Comment From: shraddhazpy
If @stevecj isn't working on it, I would want to take it.
Comment From: MarcoGorelli
go ahead, thanks @shraddhazpy
Comment From: shraddhazpy
take
Comment From: shraddhazpy
Suggested pattern:
Pass
False
as the value todate_format
and/ordatetime_format
to indicate that the formats for columns of those types should not be set automatically.
@MarcoGorelli just wanted to ensure that this is the pattern to be followed.
Comment From: MarcoGorelli
Looks like it - I think the suggestion is to make something analogous to float_format
, but for dates