Skip to content
Snippets Groups Projects
Commit 0289a47a authored by dmt's avatar dmt
Browse files

Implement the sequence protocol in PandasBlock.

parent 1dbb400d
No related branches found
No related tags found
No related merge requests found
......@@ -37,14 +37,35 @@ class Adapter(ABC):
# TODO (dmt): Provide common base class or pandas operations.
class PandasBlock:
def __init__(self, data_block):
_LAST_THREE_COLUMNS = 3
def __init__(self, data_block, relatives=None):
self.__data_block = data_block
def __str__(self):
return str(self.__data_block)
def __getitem__(self, item):
return self.__data_block.iloc[item][:self.rows-self._LAST_THREE_COLUMNS]
def __len__(self):
return self.__data_block.shape[0]
def set_labels(self, labels):
data_frame = self.__data_block["Z"] = labels
return PandasBlock(data_frame, self.relatives)
@property
def rows(self):
return self.__data_block.shape[1]
def new_block_from(self, column_values):
data_from = self.__data_block.loc[self.__data_block["T"].isin(
column_values)]
return PandasBlock(data_from)
def get_duplicated_pairs(self, *args):
bool_series = self.__data_block.duplicated(subset=[args[0], args[1]])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment