-
Notifications
You must be signed in to change notification settings - Fork 8
/
time_series.py
43 lines (34 loc) · 1.22 KB
/
time_series.py
1
2
3
4
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Módulo `time_series` de pydatajson
Contiene funciones auxiliares para analizar catálogos con series de tiempo,
definidas según la extensión del perfil de metadatos para series de tiempo.
"""
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import with_statement
import os
def field_is_time_series(field, distribution=None):
field_may_be_ts = (
not field.get("specialType") and
not field.get("specialTypeDetail") and
(
field.get("type", "").lower() == "number" or
field.get("type", "").lower() == "integer"
) and
field.get("id")
)
distribution_may_has_ts = (
not distribution or distribution_has_time_index(distribution)
)
return field_may_be_ts and distribution_may_has_ts
def distribution_has_time_index(distribution):
for field in distribution.get('field', []):
if field.get('specialType') == 'time_index':
return True
return False
def dataset_has_time_series(dataset):
for distribution in dataset.get('distribution', []):
if distribution_has_time_index(distribution):
return True
return False