diff --git a/CHANGELOG.md b/CHANGELOG.md index c82f44e17..e9c0005d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ ## Changelog -#### 0.27.1 - 2022-03-15 +#### 0.27.2 - 2022-09-07 + +##### Bug fixes + - Fixed issue in add_at_risk_table when there were very late entries. + + +#### 0.27.1 - 2022-06-25 ##### New features - all `fit_` methods now accept a `fit_options` dict that allows one to pass kwargs to the underlying fitting algorithm. @@ -10,7 +16,7 @@ - `step_size` is removed from Cox models `fit`. See `fit_options` above. ##### Bug fixes - - fixed Cox models when "trival" matrix was passed in (one with no covariates) + - fixed Cox models when "trivial" matrix was passed in (one with no covariates) #### 0.27.0 - 2022-03-15 diff --git a/lifelines/fitters/__init__.py b/lifelines/fitters/__init__.py index 13fa93ded..f33d70b64 100644 --- a/lifelines/fitters/__init__.py +++ b/lifelines/fitters/__init__.py @@ -1278,9 +1278,7 @@ def _compute_central_values_of_raw_training_data(self, df, strata=None, name="ba return v else: - from distutils.version import LooseVersion - - if LooseVersion(pd.__version__) >= "1.1.0": + if pd.__version__ >= "1.1.0": # silence deprecation warning describe_kwarg = {"datetime_is_numeric": True} else: diff --git a/lifelines/fitters/coxph_fitter.py b/lifelines/fitters/coxph_fitter.py index 04c1d86b8..c3bf591e9 100644 --- a/lifelines/fitters/coxph_fitter.py +++ b/lifelines/fitters/coxph_fitter.py @@ -1621,7 +1621,7 @@ def _get_efron_values_single( Calculates the first and second order vector differentials, with respect to beta. Note that X, T, E are assumed to be sorted on T! - A good explanation for Efron. Consider three of five subjects who fail at the time. + A good explanation for Efron. Consider three of five subjects who fail at the same time. As it is not known a priori that who is the first to fail, so one-third of (φ1 + φ2 + φ3) is adjusted from sum_j^{5} φj after one fails. Similarly two-third of (φ1 + φ2 + φ3) is adjusted after first two individuals fail, etc. diff --git a/lifelines/plotting.py b/lifelines/plotting.py index 68b828831..0d9a46af2 100644 --- a/lifelines/plotting.py +++ b/lifelines/plotting.py @@ -504,12 +504,16 @@ def add_at_risk_counts( else: event_table_slice = f.event_table.assign(at_risk=lambda x: x.at_risk - x.removed) - event_table_slice = ( - event_table_slice.loc[:tick, ["at_risk", "censored", "observed"]] - .agg({"at_risk": lambda x: x.tail(1).values, "censored": "sum", "observed": "sum"}) # see #1385 - .rename({"at_risk": "At risk", "censored": "Censored", "observed": "Events"}) - ) - counts.extend([int(c) for c in event_table_slice.loc[rows_to_show]]) + if not event_table_slice.loc[:tick].empty: + event_table_slice = ( + event_table_slice.loc[:tick, ["at_risk", "censored", "observed"]] + .agg({"at_risk": lambda x: x.tail(1).values, "censored": "sum", "observed": "sum"}) # see #1385 + .rename({"at_risk": "At risk", "censored": "Censored", "observed": "Events"}) + .fillna(0) + ) + counts.extend([int(c) for c in event_table_slice.loc[rows_to_show]]) + else: + counts.extend([0 for _ in range(n_rows)]) if n_rows > 1: if tick == ax2.get_xticks()[0]: diff --git a/lifelines/version.py b/lifelines/version.py index f74a81744..a8f10fce1 100644 --- a/lifelines/version.py +++ b/lifelines/version.py @@ -1,4 +1,4 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -__version__ = "0.27.1" +__version__ = "0.27.2"