Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
John Bogaardt committed Dec 17, 2019
1 parent 648350a commit 4afb2b3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions xlcompose/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4afb2b3

Please sign in to comment.