0
我根據我想繼續篩選我的熊貓數據幀熊貓:無效的類型比較
categoryList=['Parameter1', 'Parameter1', 'Parameter2', 'Parameter2']
conditionList=['b1', 'b41', 'm1', 'm2']
conditionDescList=['>', 'btn', '<=', 'btn']
conditionParamList=['1000', '2:3', '0.5', '0.1:0.3']
現在,我想下面的代碼從過濾行4名列表我2基於categoryList
k =0
for i in conditionDescList:
if(categoryList[k]=='Parameter1'):
if(i=='btn'):
arrValues=conditionParamList[k].split(":")
minVal=arrValues[0]
maxVal=arrValues[1]
df_custid_marker=df_custid_marker[(df_custid_marker[conditionList[k]] > minVal) & (df_custid_marker[conditionList[k]] < maxVal)]
elif(i=='>'):
df_custid_marker=df_custid_marker[(df_custid_marker[conditionList[k]] > conditionParamList[k])]
elif(i=='<'):
df_custid_marker=df_custid_marker[(df_custid_marker[conditionList[k]] < conditionParamList[k])]
elif(i=='<='):
df_custid_marker=df_custid_marker[(df_custid_marker[conditionList[k]] < conditionParamList[k]) | (df_custid_marker[conditionList[k]] == conditionParamList[k])]
elif(i=='>='):
df_custid_marker=df_custid_marker[(df_custid_marker[conditionList[k]] > conditionParamList[k]) | (df_custid_marker[conditionList[k]] == conditionParamList[k])]
else:
df_custid_marker=df_custid_marker[(df_custid_marker[conditionList[k]] == conditionParamList[k])]
k+=1
k =0
for i in conditionDescList:
if(categoryList[k]=='Parameter2'):
if(i=='btn'):
arrValues=conditionParamList[k].split(":")
minVal=arrValues[0]
maxVal=arrValues[1]
df_custid_bp=df_custid_bp[(df_custid_bp[conditionList[k]] > minVal) & (df_custid_bp[conditionList[k]] < maxVal)]
elif(i=='>'):
df_custid_bp=df_custid_bp[(df_custid_bp[conditionList[k]] > conditionParamList[k])]
elif(i=='<'):
df_custid_bp=df_custid_bp[(df_custid_bp[conditionList[k]] < conditionParamList[k])]
elif(i=='<='):
df_custid_bp=df_custid_bp[(df_custid_bp[conditionList[k]] < conditionParamList[k]) | (df_custid_bp[conditionList[k]] == conditionParamList[k])]
elif(i=='>='):
df_custid_bp=df_custid_bp[(df_custid_bp[conditionList[k]] > conditionParamList[k]) | (df_custid_bp[conditionList[k]] == conditionParamList[k])]
else:
df_custid_bp=df_custid_bp[(df_custid_bp[conditionList[k]] == conditionParamList[k])]
k+=1
現在我得到以下錯誤<=
df_custid_marker=df_custid_marker[(df_custid_marker[conditionList[k]] < conditionParamList[k]) | (df_custid_marker[conditionList[k]] == conditionParamList[k])]
df_custid_marker
,
df_custid_bp
)
raise TypeError("invalid type comparison")