-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from MannLabs/remove_index_column
Remove index column
- Loading branch information
Showing
16 changed files
with
82 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Harmonize the input data to a common format.""" | ||
|
||
import pandas as pd | ||
|
||
from alphastats import BaseLoader | ||
from alphastats.keys import Cols | ||
|
||
|
||
class DataHarmonizer: | ||
"""Harmonize input data to a common format.""" | ||
|
||
def __init__(self, loader: BaseLoader): | ||
self._rename_dict = {loader.index_column: Cols.INDEX} | ||
|
||
def get_harmonized_rawinput(self, rawinput: pd.DataFrame) -> pd.DataFrame: | ||
"""Harmonize the rawinput data to a common format.""" | ||
for target_name in self._rename_dict.values(): | ||
if target_name in rawinput.columns: | ||
raise ValueError( | ||
f"Column name {target_name} already exists in rawinput. Please rename the column." | ||
) | ||
|
||
return rawinput.rename( | ||
columns=self._rename_dict, | ||
errors="raise", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"""String constants for accessing columns.""" | ||
|
||
|
||
class Cols: | ||
"""String constants for accessing columns of the main dataframe in DataSet.""" | ||
|
||
INDEX = "index_" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.