PatsyError:数据参数和列之间的行数不匹配(statsmodels)

问题描述 投票:0回答:1

我正在使用带有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'])
pandas statsmodels patsy
1个回答
0
投票

以防万一其他人遇到这个问题。解决方案是只重命名所有列并删除所有特殊字符,例如',','/','&'等。

© www.soinside.com 2019 - 2024. All rights reserved.