From 4afb2b3456cc057b61ff7f106039ff926e595af2 Mon Sep 17 00:00:00 2001 From: John Bogaardt Date: Tue, 17 Dec 2019 15:00:39 -0700 Subject: [PATCH] patch --- xlcompose/core.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xlcompose/core.py b/xlcompose/core.py index c68ae08..72cd796 100644 --- a/xlcompose/core.py +++ b/xlcompose/core.py @@ -443,17 +443,19 @@ def format_validation(self, formats): 'datetime64[ns]': {'num_format': 'yyyy-mm-dd hh:mm', 'align': 'center'}, 'object': {'align': 'left'}, } + cols = self.data.dtypes.reset_index().drop_duplicates().set_index('index').iloc[:,0].astype(str) self.formats = { k: base_formats.get(v, base_formats['object']) - for k, v in dict(self.data.dtypes.astype(str)).items() + for k, v in dict(cols).items() } + if type(formats) is list: self.formats.update(dict(zip(self.data.columns, formats))) elif type(formats) is str: self.formats.update(dict(zip( self.data.columns, [{'num_format': formats}] * len(self.data.columns)))) - elif type(formats) is dict: + elif type(formats) is dict and formats != {}: if list(formats.keys())[0] not in self.data.columns: self.formats.update(dict(zip( self.data.columns,