0
私は4つのリストを持って、私は継続的にパンダ:無効なタイプの比較
categoryList=['Parameter1', 'Parameter1', 'Parameter2', 'Parameter2']
conditionList=['b1', 'b41', 'm1', 'm2']
conditionDescList=['>', 'btn', '<=', 'btn']
conditionParamList=['1000', '2:3', '0.5', '0.1:0.3']
私のパンダのデータフレームをフィルタリングする内容に基づいて、今、私は私から行をフィルタリングするためのコードの下にしようとしています今、私は<=
df_custid_marker=df_custid_marker[(df_custid_marker[conditionList[k]] < conditionParamList[k]) | (df_custid_marker[conditionList[k]] == conditionParamList[k])]
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
categoryList
に基づいて2データフレーム(df_custid_marker
、df_custid_bp
)
raise TypeError("invalid type comparison")