TabPy表内卡方检验

2024-09-30 16:36:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一本带综合标签的表格书 我想计算卡方检验并得到p值

SCRIPT_REAL(
"from scipy.stats import chi2_contingency 
data = [[_arg1, _arg2], [_arg3, arg4]] 
stat, p, dof, expected = chi2_contingency(data) 
return p"
, sum([orders A]), sum([not order A]), sum([orders B]), sum([not order B]))

但是我收到了这个错误

Unable to complete action
An error occurred while communicating with the Analytics Extension.
Error Code: 6116DD27
Error processing script
TypeError : '<' not supported between instances of 'NoneType' and 'int'

请帮帮我 我在tableau中尝试了同样的逻辑,一切都很顺利 但是如何使用Python呢?我不知道

当我在数据中输入一些数字而不使用参数时,它是有效的

SCRIPT_REAL(
"from scipy.stats import chi2_contingency 
data = [[100, 120], [100, 130]] 
stat, p, dof, expected = chi2_contingency(data) 
return p"
, sum([orders A]), sum([not order A]), sum([orders B]), sum([not order B])
)

Tags: fromimportdatastatsscriptnotorderscipy