File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ classifiers = [
3838dependencies = [
3939 " numpy" ,
4040 " pandas>=2.1.1" ,
41+ " pyarrow" ,
4142 " typing-extensions" ,
4243]
4344
Original file line number Diff line number Diff line change 1515if TYPE_CHECKING :
1616 from os import PathLike
1717
18+ def _apply_numeric (col : pd .Series ) -> pd .Series :
19+ try :
20+ return pd .to_numeric (col )
21+ except ValueError :
22+ return col
1823
1924class StarParser :
2025 filename : Path
@@ -104,15 +109,15 @@ def _parse_loop_block(self) -> pd.DataFrame:
104109 df = pd .DataFrame (np .zeros (shape = (0 , n_cols )))
105110 else :
106111 df = pd .read_csv (
107- StringIO (loop_data .replace ("'" ,'"' )),
108- delim_whitespace = True ,
112+ StringIO (loop_data .replace ("'" , '"' )),
113+ delimiter = r'\s+' ,
109114 header = None ,
110115 comment = '#' ,
111116 keep_default_na = False
112117 )
113- df_numeric = df .apply (pd . to_numeric , errors = 'ignore' )
118+ df_numeric = df .apply (_apply_numeric )
114119 # Replace columns that are all NaN with the original string columns
115- df_numeric . loc [:, df_numeric .isna ().all ()] = df . loc [:, df_numeric .isna ().all ()]
120+ df_numeric [ df_numeric . columns [ df_numeric .isna ().all ()]] = df [ df_numeric . columns [ df_numeric .isna ().all ()] ]
116121 df = df_numeric
117122 df .columns = loop_column_names
118123 return df
You can’t perform that action at this time.
0 commit comments