我有一个 pandas 列名列表(由所有虚拟变量组成),我想将其转换为公式字符串以复制和粘贴用于 statsmodels。
有没有办法以编程方式做到这一点?
示例代码
list = ['yrs_owned_model_28', 'yrs_owned_model_32', 'yrs_owned_model_35',
'cm_ded_model_0', 'cm_ded_model_100', 'cm_ded_model_250',
'cm_ded_model_500', 'cm_ded_model_750', 'cm_ded_model_1000',
'cm_ded_model_2500']
期望的输出:
'yrs_owned_model_28 + yrs_owned_model_32 + yrs_owned_model_35 + cm_ded_model_0 + cm_ded_model_100 + cm_ded_model_250 + cm_ded_model_500 + cm_ded_model_750 + cm_ded_model_1000 + cm_ded_model_2500'