Commit 2aa47efd authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update dataframes to add the duration column to all sources.

parent 1951876d
......@@ -356,6 +356,7 @@ def get_items(**kwargs):
* batch_number (str)
* birth_date (str)
* domain (str)
* duration (float): in days
* end_date (date): undefined dates are forced to ``DATE_MAX``
* first_name (str)
* history_note (str)
......@@ -437,6 +438,9 @@ def get_items(**kwargs):
start_date=lambda x: x.start_date.fillna(DATE_MIN),
end_date=lambda x: x.end_date.fillna(DATE_MAX)))
df["duration"] = (elapse_time(df.start_date, df.end_date, date.today())
.apply(lambda x: x.days))
return df
......@@ -489,6 +493,7 @@ def get_items_per_year(**kwargs):
* batch_number (str)
* birth_date (str)
* domain (str)
* duration (float): in days
* end_date (date): undefined dates are forced to ``DATE_MAX``
* first_name (str)
* history_note (str)
......@@ -553,6 +558,7 @@ def get_items_small(**kwargs):
* id_projects (int)
* id_teams (int)
* duration (float): in days
* end_date (date): undefined dates are forced to ``DATE_MAX``
* start_date (date): undefined dates are forced to ``DATE_MIN``
......@@ -592,6 +598,9 @@ def get_items_small(**kwargs):
start_date=lambda x: x.start_date.fillna(DATE_MIN),
end_date=lambda x: x.end_date.fillna(DATE_MAX)))
df["duration"] = (elapse_time(df.start_date, df.end_date, date.today())
.apply(lambda x: x.days))
return df
......@@ -638,6 +647,7 @@ def get_items_small_per_year(**kwargs):
* id_projects (int)
* id_teams (int)
* duration (float): in days
* end_date (date): undefined dates are forced to ``DATE_MAX``
* start_date (date): undefined dates are forced to ``DATE_MIN``
* year (int)
......@@ -690,6 +700,7 @@ def get_objectlike_items(**kwargs):
* agency (str)
* batch_number (str)
* domain (str)
* duration (float): in days
* end_date (date): undefined dates are forced to ``DATE_MAX``
* history_note (str)
* object_categories_category (str)
......@@ -752,6 +763,9 @@ def get_objectlike_items(**kwargs):
start_date=lambda x: x.start_date.fillna(DATE_MIN),
end_date=lambda x: x.end_date.fillna(DATE_MAX)))
df["duration"] = (elapse_time(df.start_date, df.end_date, date.today())
.apply(lambda x: x.days))
return df
......@@ -799,6 +813,7 @@ def get_objectlike_items_per_year(**kwargs):
* agency (str)
* batch_number (str)
* domain (str)
* duration (float): in days
* end_date (date): undefined dates are forced to ``DATE_MAX``
* history_note (str)
* object_categories_category (str)
......@@ -858,6 +873,7 @@ def get_peoplelike_items(**kwargs):
* agency (str)
* birth_date (str)
* domain (str)
* duration (float): in days
* end_date (date): undefined dates are forced to ``DATE_MAX``
* first_name (str)
* full_name(str)
......@@ -926,6 +942,9 @@ def get_peoplelike_items(**kwargs):
start_date=lambda x: x.start_date.fillna(DATE_MIN),
end_date=lambda x: x.end_date.fillna(DATE_MAX)))
df["duration"] = (elapse_time(df.start_date, df.end_date, date.today())
.apply(lambda x: x.days))
return df
......@@ -1001,6 +1020,7 @@ def get_people_per_year(**kwargs):
* percentage
* period_start (date):
* period_end (date):
* period_duraton (float): in days
* project (str)
* start_date (date): undefined dates are forced to ``DATE_MIN``
* team (str)
......@@ -1015,6 +1035,7 @@ def get_people_per_year(**kwargs):
# it is temporarily columns which are used in coverage computation
df = (to_items_per_year(get_peoplelike_items, **kwargs)
.drop("duration", axis="columns")
.assign(
period=lambda x:
x.apply(lambda y:
......@@ -1077,6 +1098,10 @@ def get_people_per_year(**kwargs):
team=lambda x: pd.Categorical(x.team)))
df["period_duration"] = \
(elapse_time(df.period_start, df.period_end, date.today())
.apply(lambda x: x.days))
return df
......@@ -1124,6 +1149,7 @@ def get_peoplelike_items_per_year(**kwargs):
* agency (str)
* birth_date (str)
* domain (str)
* duration (float): in days
* end_date (date): undefined dates are forced to ``DATE_MAX``
* first_name (str)
* full_name (str)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment