def load_schema(self, indicator): df = indicator.data schema = describe_schema(df) non_disaggregation_columns = indicator.options.get_non_disaggregation_columns( ) non_disaggregation_special_columns = [ indicator.options.get_series_column(), indicator.options.get_unit_column(), ] for column in indicator.data.columns: if column in non_disaggregation_columns and column not in non_disaggregation_special_columns: continue unique = df[column].unique() unique = unique[~pd.isnull(unique)] unique = unique.tolist() + [''] schema.get_field(column).constraints['enum'] = unique return schema
def test_schema_to_copy(): source = describe_schema("data/table.csv") target = source.to_copy() assert source is not target assert source == target
def test_describe_schema(): schema = describe_schema("data/leading-zeros.csv") assert schema == {"fields": [{"name": "value", "type": "integer"}]}