当我尝试拟合 Coxph 模型时收到以下错误
5797 if col_name in dtype:
5798 results.append(
-> 5799 col.astype(dtype=dtype[col_name], copy=copy, errors=errors)
5800 )
5801 else:
/opt/python/3.8.0/lib/python3.8/site-packages/pandas/core/generic.py in astype(self, dtype, copy, errors)
5780 if self.ndim == 1: # i.e. Series
5781 if len(dtype) > 1 or self.name not in dtype:
-> 5782 raise KeyError(
5783 "Only the Series name can be used for "
5784 "the key in Series dtype mappings."
KeyError: 'Only the Series name can be used for the key in Series dtype mappings.'
我已经检查了作为解决方案之一中的问题给出的列名称。但它们都不起作用。
以下是我的coxph模型代码:
from lifelines import CoxPHFitter
cph = CoxPHFitter()
results_fin = cph.fit(df, duration_col='Months', event_col='Event')
results_fin.print_summary()
“事件”和“月份”列都是数字。 请帮助修复错误。
我也遇到了同样的问题,找不到合适的解决方案。我认为这个功能有一些bug,会向网站报告