techtonique_apis.techto_survival

 1import tempfile
 2import pandas as pd
 3from xlwings import func, arg, ret
 4from .techtonique_apis import TechtoniqueAPI
 5
 6api = TechtoniqueAPI()
 7
 8
 9@func
10@arg("df", index=False, doc="Excel range with columns for survival data.")
11@arg("method", doc='Survival analysis method (default: "km")')
12@arg(
13    "patient_id",
14    doc="(For machine learning 'method's) Patient ID for individual survival curve",
15)
16@ret(index=False, doc="Survival curve results as a table for Excel")
17def techto_survival(
18    df: pd.DataFrame,
19    method: str = "km",
20    patient_id: int = None,
21) -> pd.DataFrame:
22    """
23    Survival analysis: pass a survival dataset as a DataFrame from Excel, return survival curve.
24
25    Excel/xlwings custom function: Survival analysis on a table from Excel using the Techtonique API.
26
27    Parameters
28    ----------
29
30    df : pd.DataFrame
31        The input survival data as a DataFrame (from Excel range).
32
33    method : str, default "km"
34        Survival analysis method to use.
35
36    patient_id : int, optional
37        For machine learning methods, patient ID for individual survival curve.
38
39    Returns
40    -------
41
42    pd.DataFrame
43        Survival curve results as a DataFrame for Excel.
44
45    ---
46    xlwings lite docstring (for Excel help):
47    Survival analysis on a table from Excel using the Techtonique API.
48    - df: Excel range with columns for survival data.
49    - method: Survival analysis method (default: km).
50    - patient_id: (For machine learning methods) Patient ID for individual survival curve.
51    Returns: Survival curve results as a table for Excel.
52    """
53    with tempfile.NamedTemporaryFile(suffix=".csv", delete=False) as tmp:
54        df.to_csv(tmp.name, index=False)
55        result = api.survival_curve(
56            file_path=tmp.name,
57            method=method,
58            patient_id=patient_id,
59        )
60    return pd.DataFrame(result)
@func
@arg('df', index=False, doc='Excel range with columns for survival data.')
@arg('method', doc='Survival analysis method (default: "km")')
@arg('patient_id', doc="(For machine learning 'method's) Patient ID for individual survival curve")
@ret(index=False, doc='Survival curve results as a table for Excel')
def techto_survival( df: pandas.DataFrame, method: str = 'km', patient_id: int = None) -> pandas.DataFrame:
10@func
11@arg("df", index=False, doc="Excel range with columns for survival data.")
12@arg("method", doc='Survival analysis method (default: "km")')
13@arg(
14    "patient_id",
15    doc="(For machine learning 'method's) Patient ID for individual survival curve",
16)
17@ret(index=False, doc="Survival curve results as a table for Excel")
18def techto_survival(
19    df: pd.DataFrame,
20    method: str = "km",
21    patient_id: int = None,
22) -> pd.DataFrame:
23    """
24    Survival analysis: pass a survival dataset as a DataFrame from Excel, return survival curve.
25
26    Excel/xlwings custom function: Survival analysis on a table from Excel using the Techtonique API.
27
28    Parameters
29    ----------
30
31    df : pd.DataFrame
32        The input survival data as a DataFrame (from Excel range).
33
34    method : str, default "km"
35        Survival analysis method to use.
36
37    patient_id : int, optional
38        For machine learning methods, patient ID for individual survival curve.
39
40    Returns
41    -------
42
43    pd.DataFrame
44        Survival curve results as a DataFrame for Excel.
45
46    ---
47    xlwings lite docstring (for Excel help):
48    Survival analysis on a table from Excel using the Techtonique API.
49    - df: Excel range with columns for survival data.
50    - method: Survival analysis method (default: km).
51    - patient_id: (For machine learning methods) Patient ID for individual survival curve.
52    Returns: Survival curve results as a table for Excel.
53    """
54    with tempfile.NamedTemporaryFile(suffix=".csv", delete=False) as tmp:
55        df.to_csv(tmp.name, index=False)
56        result = api.survival_curve(
57            file_path=tmp.name,
58            method=method,
59            patient_id=patient_id,
60        )
61    return pd.DataFrame(result)

Survival analysis: pass a survival dataset as a DataFrame from Excel, return survival curve.

Excel/xlwings custom function: Survival analysis on a table from Excel using the Techtonique API.

Parameters

df : pd.DataFrame The input survival data as a DataFrame (from Excel range).

method : str, default "km" Survival analysis method to use.

patient_id : int, optional For machine learning methods, patient ID for individual survival curve.

Returns

pd.DataFrame Survival curve results as a DataFrame for Excel.


xlwings lite docstring (for Excel help): Survival analysis on a table from Excel using the Techtonique API.

  • df: Excel range with columns for survival data.
  • method: Survival analysis method (default: km).
  • patient_id: (For machine learning methods) Patient ID for individual survival curve. Returns: Survival curve results as a table for Excel.