Commit 1951876d authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update dateframes to add the function elapse_time.

parent 42fc15b7
......@@ -10,6 +10,7 @@ from dataframes import (active_period,
DATE_MIN,
db2df,
debug_df,
elapse_time,
expand_per_year,
full_name,
get_column_names,
......
......@@ -193,6 +193,27 @@ def debug_df(df, opt=""):
print df
def elapse_time(start_date, end_date, xdate):
"""Vectorized function to compute the elapse time between the starting date
and xdate or end_date:
* it is computed between the start_date and the end_date
when the end_date is above xdate
* otherwise it is computed between the start_date and xdate
Args:
start_date (pandas.Series): starting date for items
end_date (pandas.Series): ending date for items
xdate (date)
Returns:
pandas.Series:
with the timedelta in days
"""
return end_date.mask(end_date > xdate, xdate) - start_date
def expand_per_year(df, year_start, year_end):
"""Expand the list of active items between year_start and year_end to
a list of active items per year. An item appears several time when it
......
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