我正在与使用R风格公式的状态模型与Patsy包一起工作,并收到一个我无法理解的错误,任何提示或技巧都将不胜感激。
PatsyError:数据参数与C(“Industry_Banking&CapitalMarkets”)之间的行数不匹配(8137对1)
DataFrame确实有8137行,没有丢失的数据。
完整代码如下
mixed = smf.mixedlm("""count_SoldServiceName ~ date_int + AzureActiveEngagementCount + AzureEngagementPartnerCount
+ DCount_learning_path_name + Industry_Automotive + C('Industry_Banking&CapitalMarkets') + C('Industry_Chemicals&Agrochemicals') + Industry_CivilianGovernment
+ Industry_ConsumerGoods + C('Industry_Defense&Intelligence') + Industry_DiscreteManufacturing + Industry_Energy + Industry_Gaming
+ Industry_HealthPayor + Industry_HealthProvider + Industry_HigherEducation + Industry_Insurance + C('Industry_Media&Entertainment') + Industry_Nonprofit
+ Industry_PartnerProfessionalServices + Industry_Pharmaceuticals + C('Industry_Primary&SecondaryEdu/K-12') + Industry_ProfessionalServices
+ C('Industry_PublicSafety&Justice') + Industry_Retailers + Industry_SmartSpaces + Industry_Telecommunications + C('Industry_Travel,Transport&Hospitality')
+ Industry_other + InvestmentArea_AA + InvestmentArea_ACO + InvestmentArea_CSE + InvestmentArea_CSM + InvestmentArea_ECIF + InvestmentArea_FT
+ InvestmentArea_GBB + InvestmentArea_PAL + active_flag_int + annual_sales_in_us_dollars + commitment_int
+ completed_lp_learners + edx_number_completed_courses + employees_total + esi_offer_int
+ health_int + s500_int + segmentname_int + fundamentals_flag + role_based_flag"""
,workloads_agg
,groups=workloads_agg['tpid_sub']
,exog_re=workloads_agg['date_int']
,missing='drop'
,use_sqrt=True)
mixed_fit = mixed_complete2.fit(method=['bfgs', 'lbfgs', 'cg','powell'])发布于 2019-11-07 01:11:38
以防其他人碰到这件事。解决方案是重命名所有列,并删除所有特殊字符的实例,如“、”、“/”、“和”等。
https://stackoverflow.com/questions/58740329
复制相似问题