Skip to content

Commit

Permalink
Corrijo el cálculo de time_index_size
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslavandeira committed Sep 5, 2018
1 parent 6c7c8ea commit 3ed2884
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions series_tiempo_ar_api/libs/indexing/indexer/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def update_enhanced_meta(serie: pd.Series, catalog_id: str, distribution_id: str
meta_keys.INDEX_START: serie.index.min().date(),
meta_keys.INDEX_END: serie.index.max().date(),
meta_keys.PERIODICITY: meta_keys.get(field.distribution, meta_keys.PERIODICITY),
meta_keys.INDEX_SIZE: serie.index.size,
meta_keys.INDEX_SIZE: _get_index_size(serie),
meta_keys.DAYS_SINCE_LAST_UPDATE: days_since_update,
meta_keys.LAST_VALUE: last,
meta_keys.SECOND_TO_LAST_VALUE: second_to_last,
Expand All @@ -34,7 +34,7 @@ def update_enhanced_meta(serie: pd.Series, catalog_id: str, distribution_id: str
field.enhanced_meta.update_or_create(key=meta_key, defaults={'value': value})


def _get_last_day_of_period(serie: pd.Series, periodicity: str) -> int:
def _get_last_day_of_period(serie: pd.Series, periodicity: str) -> pd.datetime:
frequencies_map_end = {
"R/P1Y": "A",
"R/P6M": "6M",
Expand All @@ -45,3 +45,8 @@ def _get_last_day_of_period(serie: pd.Series, periodicity: str) -> int:
period = pd.to_datetime(serie.index.max()).to_period(frequencies_map_end[periodicity])
last_day = period.to_timestamp(how='end')
return last_day


def _get_index_size(serie: pd.Series):
# Filtro los NaN antes y después de la serie
return len(serie[serie.first_valid_index():serie.last_valid_index()])

0 comments on commit 3ed2884

Please sign in to comment.