(self, file_or_data: [Path, pd.DataFrame], calendar_list: List[pd.Timestamp])
| 269 | np.hstack([date_index, _df[field]]).astype("<f").tofile(str(bin_path.resolve())) |
| 270 | |
| 271 | def _dump_bin(self, file_or_data: [Path, pd.DataFrame], calendar_list: List[pd.Timestamp]): |
| 272 | if not calendar_list: |
| 273 | logger.warning("calendar_list is empty") |
| 274 | return |
| 275 | if isinstance(file_or_data, pd.DataFrame): |
| 276 | if file_or_data.empty: |
| 277 | return |
| 278 | code = fname_to_code(str(file_or_data.iloc[0][self.symbol_field_name]).lower()) |
| 279 | df = file_or_data |
| 280 | elif isinstance(file_or_data, Path): |
| 281 | code = self.get_symbol_from_file(file_or_data) |
| 282 | df = self._get_source_data(file_or_data) |
| 283 | else: |
| 284 | raise ValueError(f"not support {type(file_or_data)}") |
| 285 | if df is None or df.empty: |
| 286 | logger.warning(f"{code} data is None or empty") |
| 287 | return |
| 288 | |
| 289 | # try to remove dup rows or it will cause exception when reindex. |
| 290 | df = df.drop_duplicates(self.date_field_name) |
| 291 | |
| 292 | # features save dir |
| 293 | features_dir = self._features_dir.joinpath(code_to_fname(code).lower()) |
| 294 | features_dir.mkdir(parents=True, exist_ok=True) |
| 295 | self._data_to_bin(df, calendar_list, features_dir) |
| 296 | |
| 297 | @abc.abstractmethod |
| 298 | def dump(self): |
nothing calls this directly
no test coverage detected