我试图将sql代码转换为pandas脚本,并遇到以下错误:

时间:2019-05-09 17:23:23

标签: python sql pandas

我的查询如下:

"UPDATE " & tblMaster & " SET Reason_Code='" & strReason & "', Failure_Status='Failed', Failure_date'" & strUDate & "' WHERE Name='" & strName & "' AND date>'" & strUDate & "' AND date<'" & strLDate & "'"

查询将为每个事件更新并填充Reason_Code,Failure_Date和Failure_Status列

试图将以上查询转换为python pandas。  这是我尝试过的代码:

Master11.loc[(Master11.Name == failure.Name ) & (Master11.Date > failure.Failure_Date) & (Master11.Date < failure.Install_Date), 'Reason_Code'] = failure.Reason_Code
Master11.loc[(Master11.Name == failure.Name ) & (Master11.Date > failure.Failure_Date) & (Master11.Date < failure.Install_Date), 'Failure_Status'] = 'Failed'
Master11.loc[(Master11.Name == failure.Name ) & (Master11.Date > failure.Failure_Date) & (Master11.Date < failure.Install_Date), 'Failure_Status'] = failure.Failure_Date

ValueError:只能比较标记相同的Series对象

样本输入: enter image description here

样本输出: enter image description here

0 个答案:

没有答案