Passed
Push — dev ( 5faf7b...5a9f48 )
by Konstantinos
01:22
created

PDTabularRetriever.row()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nop 3
1
from green_magic.data.interfaces import TabularRetriever, TabularIterator, TabularReporter
2
3
4
class PDTabularRetriever(TabularRetriever):
5
    """The observation object is the same as the one your return from 'from_json_lines'"""
6
    def column(self, identifier, data):
7
        return data.observations[identifier]
8
9
    def row(self, identifier, data):
10
        return data.observations.loc(identifier)
11
12
    def nb_columns(self, data):
13
        return len(data.observations.columns)
14
15
    def nb_rows(self, data):
16
        return len(data.observations)
17
18
    def get_numerical_attributes(self, data):
19
        return data.observations._get_numeric_data().columns.values
20
21
class PDTabularIterator(TabularIterator):
22
    """The observation object is the same as the one your return from 'from_json_lines'"""
23
24
    def columnnames(self, data):
25
        return [_ for _ in data.observations.columns]
26
27
    def iterrows(self, data):
28
        return iter(data.observations.iterrows())
29
30
    def itercolumns(self, data):
31
        return iter(data.observations[column] for column in data.observations.columns)
32
33
class PDTabularReporter(TabularReporter):
34
    def column_names(self, data):
35
        return data.observations.columns
36
37