Holger Frey
4 years ago
6 changed files with 27 additions and 20 deletions
@ -0,0 +1,6 @@
@@ -0,0 +1,6 @@
|
||||
|
||||
def split_data_frame(data_frame, column): |
||||
""" splits a data frame on unique column values """ |
||||
values = data_frame[column].unique() |
||||
masks = {value: (data_frame[column] == value) for value in values} |
||||
return {value: data_frame[mask] for value, mask in masks.items()} |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
|
||||
from .conftest import EXAMPLE_DIR_WITH_PARAMS |
||||
|
||||
def test_split_data_frame(example_dir): |
||||
from sensospot_data.parser import parse_folder |
||||
from sensospot_data.utils import split_data_frame |
||||
|
||||
data_frame = parse_folder(example_dir / EXAMPLE_DIR_WITH_PARAMS) |
||||
|
||||
result = split_data_frame(data_frame, "Well.Row") |
||||
|
||||
assert set(result.keys()) == set("ABC") |
||||
for key, value_df in result.items(): |
||||
assert set(value_df["Well.Row"].unique()) == {key} |
Loading…
Reference in new issue