Skip to content

eds_scikit.biology.utils.check_data

check_data_and_select_columns_measurement

check_data_and_select_columns_measurement(data: Data)

Check the required tables and columns in the Data and extract them.

PARAMETER DESCRIPTION
data

Instantiated HiveData, PostgresData or PandasData

TYPE: Data

Source code in eds_scikit/biology/utils/check_data.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def check_data_and_select_columns_measurement(data: Data):
    """Check the required tables and columns in the Data and extract them.

    Parameters
    ----------
    data : Data
         Instantiated [``HiveData``][eds_scikit.io.hive.HiveData], [``PostgresData``][eds_scikit.io.postgres.PostgresData] or [``PandasData``][eds_scikit.io.files.PandasData]
    """
    check_tables(
        data,
        required_tables=[
            "measurement",
            "concept",
            "concept_relationship",
        ],
    )

    _measurement_required_columns = [
        "measurement_id",
        "person_id",
        "visit_occurrence_id",
        "measurement_date",
        "measurement_datetime",
        "value_source_value",
        "value_as_number",
        "unit_source_value",
        "row_status_source_value",
        "measurement_source_concept_id",
        "range_high",
        "range_low",
    ]

    _concept_required_columns = [
        "concept_id",
        "concept_name",
        "concept_code",
        "vocabulary_id",
    ]

    _relationship_required_columns = ["concept_id_1", "concept_id_2", "relationship_id"]

    check_columns(
        data.measurement,
        required_columns=_measurement_required_columns,
    )
    check_columns(data.concept, required_columns=_concept_required_columns)
    check_columns(
        data.concept_relationship,
        required_columns=_relationship_required_columns,
    )

    measurement = data.measurement
    concept = data.concept[_concept_required_columns]
    concept_relationship = data.concept_relationship[_relationship_required_columns]

    return measurement, concept, concept_relationship

check_data_and_select_columns_relationship

check_data_and_select_columns_relationship(data: Data)

Check the required tables and columns in the Data and extract them.

PARAMETER DESCRIPTION
data

Instantiated HiveData, PostgresData or PandasData

TYPE: Data

Source code in eds_scikit/biology/utils/check_data.py
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
def check_data_and_select_columns_relationship(data: Data):
    """Check the required tables and columns in the Data and extract them.

    Parameters
    ----------
    data : Data
         Instantiated [``HiveData``][eds_scikit.io.hive.HiveData], [``PostgresData``][eds_scikit.io.postgres.PostgresData] or [``PandasData``][eds_scikit.io.files.PandasData]
    """
    check_tables(
        data,
        required_tables=[
            "concept",
            "concept_relationship",
        ],
    )

    _concept_required_columns = [
        "concept_id",
        "concept_name",
        "concept_code",
        "vocabulary_id",
    ]

    _relationship_required_columns = [
        "concept_id_1",
        "concept_id_2",
        "relationship_id",
    ]

    check_columns(data.concept, required_columns=_concept_required_columns)
    check_columns(
        data.concept_relationship,
        required_columns=_relationship_required_columns,
    )

    concept = data.concept[_concept_required_columns]
    concept_relationship = data.concept_relationship[_relationship_required_columns]

    return concept, concept_relationship
Back to top