| @@ 10-31 (lines=22) @@ | ||
| 7 | # DELEGATES |
|
| 8 | # User defined (engine dependent implementations of tabular operations) |
|
| 9 | ||
| 10 | class PDTabularRetrieverDelegate(TabularRetriever): |
|
| 11 | """The observation object is the same as the one your return from 'from_json_lines'""" |
|
| 12 | ||
| 13 | @classmethod |
|
| 14 | def column(cls, identifier, data): |
|
| 15 | return data.observations[identifier] |
|
| 16 | ||
| 17 | @classmethod |
|
| 18 | def row(cls, identifier, data): |
|
| 19 | return data.observations.loc(identifier) |
|
| 20 | ||
| 21 | @classmethod |
|
| 22 | def nb_columns(cls, data): |
|
| 23 | return len(data.observations.columns) |
|
| 24 | ||
| 25 | @classmethod |
|
| 26 | def nb_rows(cls, data): |
|
| 27 | return len(data.observations) |
|
| 28 | ||
| 29 | @classmethod |
|
| 30 | def get_numerical_attributes(cls, data): |
|
| 31 | return data.observations._get_numeric_data().columns.values |
|
| 32 | ||
| 33 | ||
| 34 | class PDTabularIteratorDelegate(TabularIterator): |
|
| @@ 8-28 (lines=21) @@ | ||
| 5 | def client_pandas_tabular_implementation(): |
|
| 6 | from so_magic.data.interfaces import TabularRetriever, TabularIterator, TabularMutator |
|
| 7 | ||
| 8 | class TestPDTabularRetrieverDelegate(TabularRetriever): |
|
| 9 | """The observation object is the same as the one you return from 'from_json_lines'""" |
|
| 10 | ||
| 11 | @classmethod |
|
| 12 | def column(cls, identifier, data): |
|
| 13 | return data.observations[identifier] |
|
| 14 | ||
| 15 | def row(self, identifier, data): |
|
| 16 | return data.observations.loc(identifier) |
|
| 17 | ||
| 18 | @classmethod |
|
| 19 | def nb_columns(cls, data): |
|
| 20 | return len(data.observations.columns) |
|
| 21 | ||
| 22 | @classmethod |
|
| 23 | def nb_rows(cls, data): |
|
| 24 | return len(data.observations) |
|
| 25 | ||
| 26 | @classmethod |
|
| 27 | def get_numerical_attributes(cls, data): |
|
| 28 | return data.observations._get_numeric_data().columns.values |
|
| 29 | ||
| 30 | ||
| 31 | class TestPDTabularIteratorDelegate(TabularIterator): |
|