in playground/process_analysis/status_transition_graph.py [0:0]
def from_data_frame(cls, df: pd.DataFrame, issue_filter: IssueFilter | None = None) -> "StatusTransitionGraph":
"""
Create a StatusTransitionGraph from a Pandas DataFrame.
For advanced usage, and testing. For most use cases, use the from_database method.
Note: The DataFrame must have a column for each field in the StatusChange class.
"""
if df.empty:
raise ValueError("Provided DataFrame is empty" +
"no status transitions in the 'issue_changelogs' table were found.")
process_graph: StatusTransitionGraph = cls()
df = df.copy().sort_values(by=["issue_key", "changed_date"], ascending=True)
if issue_filter is not None:
df = issue_filter.apply(df)
previous_status_change: StatusChange = None
for item in df.itertuples(index=False):
status_change = StatusChange(*item)
process_graph.add_status_change(status_change, previous_status_change)
previous_status_change = status_change
return process_graph