Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
tev
plugin_event
Commits
1951876d
Commit
1951876d
authored
Apr 05, 2017
by
LE GAC Renaud
Browse files
Update dateframes to add the function elapse_time.
parent
42fc15b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
modules/plugin_event/__init__.py
modules/plugin_event/__init__.py
+1
-0
modules/plugin_event/dataframes.py
modules/plugin_event/dataframes.py
+21
-0
No files found.
modules/plugin_event/__init__.py
View file @
1951876d
...
...
@@ -10,6 +10,7 @@ from dataframes import (active_period,
DATE_MIN
,
db2df
,
debug_df
,
elapse_time
,
expand_per_year
,
full_name
,
get_column_names
,
...
...
modules/plugin_event/dataframes.py
View file @
1951876d
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment