Skip to content

Commit a233a5c

Browse files
authored
CLN: remove redundant openpyxl type conversions (#39782)
1 parent 7c2ff10 commit a233a5c

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

pandas/io/excel/_openpyxl.py

+3-13
Original file line numberDiff line numberDiff line change
@@ -508,24 +508,14 @@ def get_sheet_by_index(self, index: int):
508508

509509
def _convert_cell(self, cell, convert_float: bool) -> Scalar:
510510

511-
from openpyxl.cell.cell import TYPE_BOOL, TYPE_ERROR, TYPE_NUMERIC
511+
from openpyxl.cell.cell import TYPE_ERROR, TYPE_NUMERIC
512512

513513
if cell.value is None:
514514
return "" # compat with xlrd
515-
elif cell.is_date:
516-
return cell.value
517515
elif cell.data_type == TYPE_ERROR:
518516
return np.nan
519-
elif cell.data_type == TYPE_BOOL:
520-
return bool(cell.value)
521-
elif cell.data_type == TYPE_NUMERIC:
522-
# GH5394
523-
if convert_float:
524-
val = int(cell.value)
525-
if val == cell.value:
526-
return val
527-
else:
528-
return float(cell.value)
517+
elif not convert_float and cell.data_type == TYPE_NUMERIC:
518+
return float(cell.value)
529519

530520
return cell.value
531521

0 commit comments

Comments
 (0)