krish
krish

Reputation: 33

python dataset - Read a group of column and place it in seperate dataframe?

Can anybody help me as i am new to python.I having an dataset named purchasing data,where log data of every PO activity for every CaseID's are present in the dataset.

Case Id     Activity                                 transactionstatus                                   
1           Create Purchase Requisition                     Closed
1           Create Request for Quotation Requester          Closed
1           Analyze Request for Quotation                   Closed
1           Send Request for Quotation to Supplier          Closed
1           Create Quotation comparison Map                 Closed
1           Analyze Quotation comparison Map                Closed
1           Choose best option                              Closed
1           Settle conditions with supplier                 Closed
1           Create Purchase Order                           Closed
1           Confirm Purchase Order                          Closed
1           Deliver Goods Services                          Closed
1           Release Purchase Order                          Closed
1           Approve Purchase Order for payment              Closed
1           Send invoice                                    Closed
1           Release Supplier's Invoice                      Closed
1           Authorize Supplier's Invoice payment            Closed
1           Pay invoice                                     Closed

Here every Case Id is considered as one variable.So there are totally 1949 variable like this.

For Eg: Case Id:1 is considered as one variable from Activity column 'Create purchase Requisition' to 'Pay invoice' and then there TransactionStatus is considered as 'closed'. (as above data)

Now there are many caseID which has an transactionStatus as 'open' now what i am trying to do is that i trying to fetch all the caseId and the respective Activity(the whole data from activity 'create...' till 'analyze....') that is having a transactionstatus as 'open' and trying to place it in a seperate dataset

for eg:

Case ID Activity                                         TransactionStatus
1941    Create Purchase Requisition                            Closed
1941    Analyze Purchase Requisition                           Closed
1941    Create Request for Quotation Requester Manager         Closed
1941    Analyze Request for Quotation                           Open
1949    Create Purchase Requisition                            Closed
1949    Analyze Purchase Requisition                            Open

totally there are 196 records that are having open transactionstatus! Can anybody help me out in what way can i do this

Upvotes: 2

Views: 249

Answers (1)

Nihal
Nihal

Reputation: 5344

try this

df = df[df.loc[:, 'caseID'].isin(df[df['TransactionStatus'] == 'Open']['caseID'])]

Upvotes: 2

Related Questions