df1:
- id, Name, Lastname, Account, ProofID1, ProofID2, status
- 1, ab1, dc1, 312, 1224, 111, 3
- 2, ab2, dc2, 434, 1225, 112, 4
- 3, ab3, dc3, 578, 1226, 111, 3
- 4, ab4, dc4, 624, 1227, 112, 4
- 5, ab5, dc5, 684, 1228, 113, 5
I am trying to design a function to copy specific columns according to their statuses.
I have designed a for loop, but I am unable to write the code for copying the data.
- for Name,Lname,Acc,ID1,ID2,status in df1[['Name','Lastname','Account','ProofID1','ProofID2','status']].itertuples(index=False):
- if status==3: #for df3 #piece of code
- elif status== 4: #for df4 #piece of code
- elif status== 5: #for df5 #piece of code
Expected output:
- df2: (for status= 3)
- id, Name, Account, ProofID1, ProofID2
- 1, ab1, 312, 1224, 111, 3
- 3, ab3, 578, 1226, 111, 3
- df4: (for status= 5)
- id, Name, Account, ProofID1, ProofID2
- 5, ab5, 684, 1228, 113, 5