Skip to content
Snippets Groups Projects
Commit 6a4cdb30 authored by pswain's avatar pswain
Browse files

feature(dataloader): get sub_df to return a smaller data frame

parent c50a8dee
No related branches found
No related tags found
No related merge requests found
...@@ -509,6 +509,30 @@ class dataloader: ...@@ -509,6 +509,30 @@ class dataloader:
""" """
return self.df.pivot(y, x, signal) return self.df.pivot(y, x, signal)
def sub_df(self, signal, duration_threshold):
"""
Find a sub dataframe of dataloader's main dataframe.
Parameters
----------
duration_threshold: float
Specifies the fraction of the total duration of the time-lapse
experiment for which a cell must be present in a trap.
"""
if duration_threshold < 0 or duration_threshold > 1:
print(
f"The threshold must be a fraction, not {duration_threshold}."
)
return
else:
wdf = self.wide_df(signal)
keep = (
wdf.notna().sum(axis=1) > duration_threshold * wdf.columns.size
).values
ids_to_keep = list(wdf.index[keep])
sdf = self.df[self.df.id.isin(ids_to_keep)]
return sdf
def get_time_series(self, signal, group=None): def get_time_series(self, signal, group=None):
""" """
Extract a signal as a 2D array with each row a time series. Extract a signal as a 2D array with each row a time series.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment