Posts

Showing posts with the label match

Match three 'isin' statements and return index where they match, then replace value if all conditions are satisfied

Image
Clash Royale CLAN TAG #URR8PPP Match three 'isin' statements and return index where they match, then replace value if all conditions are satisfied I want to find where three different columns in two dataframes match and then replace a value in another column if they match. How do I combine the three conditions below, perhaps in a loop form, to check if each row matches all three conditions? First two conditions - matching the values in two different columns: DATA1[DATA1[‘f_code’].isin(DATA2[‘F’])] # Column 1 DATA1[DATA1[‘b_id’].isin(DATA2[‘B’])] # Column 2 Last condition which I am writing wrong. I want the value in DATA1 'species' to match the header of DATA2 if the above two conditions are true DATA1[DATA1[‘species’] == DATA2[header = ‘SO2’] Then, if the conditions are met in that row, I want to replace the value the column named 'value' in DATA1 with the value that was under the 'SO2' header for that row. How can I do this? I tried this (not writt...

In Mongodb How to Give two different $match

In Mongodb How to Give two different $match In Db I have some sample data: Object 1 "_id" : ObjectId("5b5934bb49b") "payment" : { "paid_total" : 500, "name" : "havi", "payment_mode" : "cash", "pd_no" : "PD20725001", "invoices" : [ { "invoice_number" : "IN11803831583" } ], "type" : "Payment" } Object 2 "_id" : ObjectId("5b5934ee31e"), "patient" : { "invoice_date" : "2018-07-26", "invoiceTotal" : 2000, "pd_no" : "PD20725001", "type" : "Invoice", "invoice_number" : "IN11803831583" } Note : All the Data is In same Collection As the above shown data I have many objects in my database. How can I get the Sum from the data above of invoiceTotal and sum of paid_...