MCPcopy
hub / github.com/microsoft/qlib / _get_date

Method _get_date

scripts/dump_bin.py:148–167  ·  view source on GitHub ↗
(
        self, file_or_df: [Path, pd.DataFrame], *, is_begin_end: bool = False, as_set: bool = False
    )

Source from the content-addressed store, hash-verified

146 return datetime_d.strftime(self.calendar_format)
147
148 def _get_date(
149 self, file_or_df: [Path, pd.DataFrame], *, is_begin_end: bool = False, as_set: bool = False
150 ) -> Iterable[pd.Timestamp]:
151 if not isinstance(file_or_df, pd.DataFrame):
152 df = self._get_source_data(file_or_df)
153 else:
154 df = file_or_df
155 if df.empty or self.date_field_name not in df.columns.tolist():
156 _calendars = pd.Series(dtype=np.float32)
157 else:
158 _calendars = df[self.date_field_name]
159
160 if is_begin_end and as_set:
161 return (_calendars.min(), _calendars.max()), set(_calendars)
162 elif is_begin_end:
163 return _calendars.min(), _calendars.max()
164 elif as_set:
165 return set(_calendars)
166 else:
167 return _calendars.tolist()
168
169 def _get_source_data(self, file_path: Path) -> pd.DataFrame:
170 df = read_as_df(file_path, low_memory=False)

Callers 1

_dump_featuresMethod · 0.80

Calls 3

_get_source_dataMethod · 0.95
tolistMethod · 0.80
maxMethod · 0.80

Tested by

no test coverage detected