2

我正在使用带有 Patsy 包的 R 样式公式使用 statsmodels 并收到一个我无法正面或反面的错误,任何提示或技巧将不胜感激。

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'])
4

1 回答 1

3

以防万一其他人遇到这种情况。解决方案是重命名所有列并删除所有特殊字符的实例,如“、”、“/”、“&”等。

于 2019-11-07T01:11:38.477 回答