File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
src/power_grid_model_io/data_stores Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -93,10 +93,20 @@ def sheet_loader():
9393 sheet_data = self ._handle_duplicate_columns (data = sheet_data , sheet_name = xls_sheet_name )
9494 sheet_data = self ._process_uuid_columns (data = sheet_data , sheet_name = xls_sheet_name )
9595 sheet_data = self ._update_column_names (data = sheet_data )
96+ # Only convert large integer values to strings for columns named 'Name'
97+ for col in sheet_data .columns :
98+ if (col == "Name" or (isinstance (col , tuple ) and col [0 ] == "Name" )) and sheet_data [col ].dtype in [
99+ "float64" ,
100+ "int64" ,
101+ ]:
102+ if (sheet_data [col ].abs () >= 1e12 ).any ():
103+ sheet_data [col ] = sheet_data [col ].apply (
104+ lambda x : str (int (x ))
105+ if pd .notnull (x ) and isinstance (x , (int , float )) and abs (x ) >= 1e12
106+ else x
107+ )
96108 return sheet_data
97109
98- return sheet_loader
99-
100110 data : Dict [str , LazyDataFrame ] = {}
101111 for name , path in self ._file_paths .items ():
102112 excel_file = pd .ExcelFile (path )
You can’t perform that action at this time.
0 commit comments