# dataframe
below code just gives me similar values in two coulmns.
Thanks for your interest in this regard.
import pandas as pd table = pd.DataFrame(data = {'DateTime':['01-01-17 16:30','01-01-17 16:31','02-01-17 08:45','02-01-17 08:45','02-01-17 10:40','02-01-17 16:40','02-01-17 16:41','02-01-17 16:42','03-01-17 08:45','03-01-17 08:45','03-01-17 10:48'], 'Amount':[1000,2000,1000,1000,50000,4000,5000,9000,4000,5000,20000], 'Ref':['Deduct','Deduct','Add','Add','Add','Transfer','Transfer','Deduct','Add','Add','Deduct'], 'DrCode':[1500,1400,9000,9000,9000,1600,1700,2000,9000,9000,4000], 'CrCode':[9000,9000,1500,1400,3000,2000,2000,9000,1600,1700,9000],}) # convert the DateTime field from an string/object to datetime table['DateTime']= pd.to_datetime(table['DateTime'])i'm no where near the test of the crterias such as datetime & Amount, through a loop.
below code just gives me similar values in two coulmns.
table[table.CrCode.isin(table.DrCode) & table.DrCode.isin(table.CrCode)] Out[210]: Amount CrCode DateTime DrCode Ref 0 1000 9000 2017-01-01 16:30:00 1500 Deduct 1 2000 9000 2017-01-01 16:31:00 1400 Deduct 2 1000 1500 2017-02-01 08:45:00 9000 Add 3 1000 1400 2017-02-01 08:45:00 9000 Add 5 4000 2000 2017-02-01 16:40:00 1600 Transfer 6 5000 2000 2017-02-01 16:41:00 1700 Transfer 7 9000 9000 2017-02-01 16:42:00 2000 Deduct 8 4000 1600 2017-03-01 08:45:00 9000 Add 9 5000 1700 2017-03-01 08:45:00 9000 AddI hope there should be a way to do this.
Thanks for your interest in this regard.