AnomalyLab 0.3.1__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {anomalylab-0.3.1 → anomalylab-0.3.3/AnomalyLab.egg-info}/PKG-INFO +1 -1
- {anomalylab-0.3.1/AnomalyLab.egg-info → anomalylab-0.3.3}/PKG-INFO +1 -1
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/core/core.py +11 -4
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/fillna.py +16 -7
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/structure/panel_data.py +5 -2
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/structure/time_series.py +3 -2
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/visualization/format.py +0 -6
- {anomalylab-0.3.1 → anomalylab-0.3.3}/setup.py +1 -1
- {anomalylab-0.3.1 → anomalylab-0.3.3}/.gitattributes +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/.github/workflows/python-publish.yml +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/.gitignore +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/AnomalyLab.egg-info/SOURCES.txt +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/AnomalyLab.egg-info/dependency_links.txt +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/AnomalyLab.egg-info/requires.txt +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/AnomalyLab.egg-info/top_level.txt +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/LICENSE +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/MANIFEST.in +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/README.md +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/__init__.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/config.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/core/__init__.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/datasets/__init__.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/datasets/dataset.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/datasets/panel_data.csv +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/datasets/time_series_data.csv +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/datasets/transition_matrix.png +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/__init__.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/correlation.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/empirical.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/factor_return.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/fm_regression.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/persistence.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/portfolio.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/empirical/summary.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/__init__.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/normalize.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/outliers.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/preprocessor.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/shift.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/preprocess/truncate.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/structure/__init__.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/structure/data.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/utils/__init__.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/utils/imports.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/utils/utils.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/anomalylab/visualization/__init__.py +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/requirements.txt +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/setup.cfg +0 -0
- {anomalylab-0.3.1 → anomalylab-0.3.3}/tests/__init__.py +0 -0
|
@@ -121,8 +121,7 @@ class Panel:
|
|
|
121
121
|
|
|
122
122
|
@property
|
|
123
123
|
def fm_preprocessor(self) -> FamaMacBethRegression:
|
|
124
|
-
|
|
125
|
-
self._fm_preprocessor = FamaMacBethRegression(panel_data=self.panel_data)
|
|
124
|
+
self._fm_preprocessor = FamaMacBethRegression(panel_data=self.panel_data)
|
|
126
125
|
return self._fm_preprocessor
|
|
127
126
|
|
|
128
127
|
def format_preprocessor(self, path: str) -> FormatExcel:
|
|
@@ -355,10 +354,18 @@ class Panel:
|
|
|
355
354
|
)
|
|
356
355
|
|
|
357
356
|
def format_excel(
|
|
358
|
-
self,
|
|
357
|
+
self,
|
|
358
|
+
path: str,
|
|
359
|
+
align=True,
|
|
360
|
+
line=True,
|
|
361
|
+
convert_brackets=False,
|
|
362
|
+
adjust_col_widths=False,
|
|
359
363
|
) -> None:
|
|
360
364
|
self.format_preprocessor(path=path).process(
|
|
361
|
-
align=align,
|
|
365
|
+
align=align,
|
|
366
|
+
line=line,
|
|
367
|
+
convert_brackets=convert_brackets,
|
|
368
|
+
adjust_col_widths=adjust_col_widths,
|
|
362
369
|
)
|
|
363
370
|
|
|
364
371
|
|
|
@@ -201,12 +201,15 @@ class FillNa(Preprocessor):
|
|
|
201
201
|
|
|
202
202
|
def _warning(self, fill_columns: list[str]) -> None:
|
|
203
203
|
"""
|
|
204
|
-
|
|
204
|
+
Emit warnings regarding missing values and normalization status.
|
|
205
205
|
|
|
206
|
-
This method
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
This method performs the following checks:
|
|
207
|
+
1. It verifies if there are any missing values in the specified `fill_columns`.
|
|
208
|
+
- If no missing values are found, a warning is issued indicating this.
|
|
209
|
+
2. It checks whether the data has already been normalized.
|
|
210
|
+
- If normalized, a warning is issued that missing values were filled with zeros during normalization.
|
|
211
|
+
3. It checks whether missing values were filled previously.
|
|
212
|
+
- If so, a warning is issued to indicate that missing values have already been handled earlier.
|
|
210
213
|
|
|
211
214
|
Args:
|
|
212
215
|
fill_columns (list[str]): The list of columns to check for missing values.
|
|
@@ -215,7 +218,11 @@ class FillNa(Preprocessor):
|
|
|
215
218
|
warnings.warn(message=f"Missing values not found in {fill_columns}.")
|
|
216
219
|
if self.panel_data.normalize:
|
|
217
220
|
warnings.warn(
|
|
218
|
-
message=f"The data has already been normalized and
|
|
221
|
+
message=f"The data has already been normalized, and missing values have been filled with 0."
|
|
222
|
+
)
|
|
223
|
+
if self.panel_data.fillna:
|
|
224
|
+
warnings.warn(
|
|
225
|
+
message=f"The missing values have already been handled earlier."
|
|
219
226
|
)
|
|
220
227
|
|
|
221
228
|
|
|
@@ -224,7 +231,9 @@ if __name__ == "__main__":
|
|
|
224
231
|
|
|
225
232
|
df: DataFrame = DataSet.get_panel_data()
|
|
226
233
|
|
|
227
|
-
panel: PanelData = PanelData(
|
|
234
|
+
panel: PanelData = PanelData(
|
|
235
|
+
df=df, name="Stocks", ret="return", classifications="industry"
|
|
236
|
+
)
|
|
228
237
|
|
|
229
238
|
fill_nan: FillNa = FillNa(panel_data=panel)
|
|
230
239
|
fill_nan.fill_group_column(
|
|
@@ -61,8 +61,9 @@ class PanelData(Data):
|
|
|
61
61
|
if self.is_copy:
|
|
62
62
|
self.df = copy.deepcopy(self.df)
|
|
63
63
|
self.df[self.id] = self.df[self.id].astype(int)
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
if not isinstance(self.df[self.time].dtype, pd.PeriodDtype):
|
|
65
|
+
self.df[self.time] = pd.to_datetime(self.df[self.time], format="ISO8601")
|
|
66
|
+
self.df[self.time] = self.df[self.time].dt.to_period(freq=self.frequency)
|
|
66
67
|
self.df.sort_values(by=[self.time, self.id], inplace=True)
|
|
67
68
|
basic_column = (
|
|
68
69
|
[self.id, self.time] if self.ret is None else [self.id, self.time, self.ret]
|
|
@@ -182,6 +183,8 @@ class PanelData(Data):
|
|
|
182
183
|
raise ValueError("No classifications found.")
|
|
183
184
|
check_columns = set(self.classifications)
|
|
184
185
|
elif check_range == "characteristics":
|
|
186
|
+
if self.firm_characteristics is None:
|
|
187
|
+
raise ValueError("No firm characteristics found.")
|
|
185
188
|
check_columns = set(self.firm_characteristics)
|
|
186
189
|
else:
|
|
187
190
|
raise ValueError("Invalid check_range value.")
|
|
@@ -37,8 +37,9 @@ class TimeSeries(Data):
|
|
|
37
37
|
"""
|
|
38
38
|
if self.is_copy:
|
|
39
39
|
self.df = copy.deepcopy(self.df)
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
if not isinstance(self.df[self.time].dtype, pd.PeriodDtype):
|
|
41
|
+
self.df[self.time] = pd.to_datetime(self.df[self.time], format="ISO8601")
|
|
42
|
+
self.df[self.time] = self.df[self.time].dt.to_period(freq=self.frequency)
|
|
42
43
|
self.df = self.df.sort_values(by=self.time)
|
|
43
44
|
self.factors = list(self.df.columns)
|
|
44
45
|
self.factors.remove(self.time)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|