-1

Filter out the specific value from excel(anly columns), fetch the complete row and save in to another tab

Used Pandas

Input

Item    Units   UnitCost    Total
Pencil  95  1.99    189.05
Binder  50  19.99   999.5
Pencil  36  4.99    179.64
Pen 27  19.99   539.73
Pencil  56  2.99    167.44
Binder  60  4.99    (SRC):299.4 ---> (TGT):299.41
Pencil  75  1.99    149.25
Pencil  90  4.99    449.1
Pencil  (SRC):32 ---> (TGT):654 (SRC):1.99 ---> (TGT):1.85  (SRC):63.68 ---> (TGT):63.7
Binder  60  8.99    539.4
Pencil  90  4.99    449.1
Binder  29  1.99    57.71
Binder  81  19.99   1619.19
Pencil  35  4.99    174.65
Desk    (SRC):2 ---> (TGT):20   125 250

Expected

Item    Units   UnitCost    Total
Binder  60  4.99    (SRC):299.4 ---> (TGT):299.41
Pencil  (SRC):32 ---> (TGT):654 (SRC):1.99 ---> (TGT):1.85  (SRC):63.68 ---> (TGT):63.7
Desk    (SRC):2 ---> (TGT):20   125 250

Need to fetch where ever (SRC) in the cell

Chris
  • 29,127
  • 3
  • 28
  • 51
Mahesh
  • 29
  • 4
  • Welcome to StackOverFlow @Mahesh ! Have a look on [How to create a Minimal, Reproducible Example](https://stackoverflow.com/help/reprex) and what is a [good question](https://stackoverflow.com/help/how-to-ask). You will even have rewards at visiting those pages. We will not write code for you. Share what you have tried so far and we will try to improve it. – shaik moeed May 23 '19 at 08:46

1 Answers1

0

Use pd.Series.str.contains:

df[df.astype(str).sum(1).str.contains('SRC')]

Output:

Item                    Units                    UnitCost                          Total
5   Binder                       60                        4.99  (SRC):299.4 ---> (TGT):299.41
8   Pencil  (SRC):32 ---> (TGT):654  (SRC):1.99 ---> (TGT):1.85    (SRC):63.68 ---> (TGT):63.7
14    Desk    (SRC):2 ---> (TGT):20                         125                            250
Chris
  • 29,127
  • 3
  • 28
  • 51