-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9df68dc
commit 32a1284
Showing
12 changed files
with
725 additions
and
107 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,7 @@ | ||
a: | ||
b: | ||
c: | ||
test: 5 | ||
d: | ||
- 5=4 | ||
- 3: 6 |
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,8 @@ | ||
#! /usr/bin/python3.9 | ||
|
||
import yaml | ||
|
||
with open('test.yml') as f: | ||
yml_content = yaml.load(f, Loader=yaml.FullLoader) | ||
|
||
print(yml_content) |
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,17 @@ | ||
import numpy as np | ||
import pandas as pd | ||
|
||
from typing import Tuple, List, Any | ||
|
||
def get_csv_lines_as_df(file_path: str) -> pd.DataFrame: | ||
with open(file_path, 'r') as f: | ||
content = f.read() | ||
|
||
l_line = content.split('\n') | ||
df_line = pd.DataFrame( | ||
data=[(i, line) for i, line in enumerate(l_line, 1)], | ||
columns=['line_nr', 'line'], | ||
dtype=object, | ||
) | ||
|
||
return df_line |
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,23 @@ | ||
import numpy as np | ||
import pandas as pd | ||
|
||
from typing import Tuple, List, Any | ||
|
||
def check_df_index(df: pd.DataFrame) -> None: | ||
assert df.index.values[0] == 0 | ||
assert np.all(np.diff(df.index.values) == 1) | ||
|
||
def get_df_part_loc( | ||
df: pd.DataFrame, | ||
l_column_l_values: List[Tuple[str, List[Any]]], | ||
) -> Tuple[np.ndarray, pd.DataFrame, pd.DataFrame]: | ||
if len(l_column_l_values) == 0: | ||
arr_idx_bool = np.ones((df.shape[0], ), dtype=np.bool) | ||
return np.df | ||
|
||
column_name, l_values = l_column_l_values[0] | ||
arr_idx_bool = np.isin(df[column_name].values, l_values) | ||
for column_name, l_values in l_column_l_values[1:]: | ||
arr_idx_bool &= np.isin(df[column_name].values, l_values) | ||
|
||
return arr_idx_bool, df.loc[arr_idx_bool], df.loc[~arr_idx_bool] |
Oops, something went wrong.