通过合并两个不同的数据框列来创建新的Flag列

时间:2019-04-26 06:39:12

标签: python pandas dataframe join merge

我要通过编号和单据编号将销售发票标题与销售发票行合并,并在数据框中创建新的发票。

我想创建一个新的标志列,作为产品发货和不发货。

SELECT a.WebIncrementID as order_ID,b.Quantity,b.[Shipment Date],
CASE when a.No_ = b.[Document No_] THEN 'Shipdata' ELSE 'shipdata' END flag  FROM [Tile Mountain$Sales Invoice Header] a
INNER JOIN [Tile Mountain$Sales Invoice Line] b on(a.No_ = b.[Document No_])

UNION ALL

SELECT a.WebIncrementID as order_ID,c.Quantity,c.[Shipment Date],
CASEwhen a.No_ = c.[Document No_] THEN 'nonShipdata' ELSE 'nonshipdata' END flag  FROM [Tile Mountain$Sales Header] a
INNER JOIN [Tile Mountain$Sales Line] c on(a.No_ = c.[Document No_])

0 个答案:

没有答案