def __call__( self, data: DataTuple, split_id: int = 0 ) -> Tuple[DataTuple, DataTuple, Dict[str, float]]: del split_id train_len = round(self.train_percentage * len(data)) train = data.apply_to_joined_df( lambda df: df.iloc[:train_len].reset_index(drop=True)) train = train.replace(name=f"{data.name} - Train") test = data.apply_to_joined_df( lambda df: df.iloc[train_len:].reset_index(drop=True)) test = test.replace(name=f"{data.name} - Test") assert len(train) + len(test) == len(data) return train, test, {}
def query_dt(datatup: DataTuple, query_str: str) -> DataTuple: """Query a datatuple.""" assert isinstance(query_str, str) assert isinstance(datatup, DataTuple) def _query_func(joined_data_frame: pd.DataFrame) -> pd.DataFrame: return dataset_from_cond(joined_data_frame, cond=query_str) return datatup.apply_to_joined_df(_query_func)