0

I am using this kinda dataframe:

A  B  C  D  E
0  1  5  0  0
   2  3  1  0
   3  5  0  7
1  1  3  1  2
   3  3  3  3
2  5  1  2  1  

If user input A = 0, B = 2, I need to show C = 3 D = 1 and E = 0 OR \n

If user input A = 1, B = 1, I need to show C = 3 D = 1 and E = 2

Anurag Dabas
  • 23,866
  • 9
  • 21
  • 41
Kisna
  • 1
  • 1
  • `df.loc[(df["A"] == 0) & (df["B"] == 2), ["C", "D", "E"]]` will do selection for you. You should take a look at the [indexing and selecting data guide](https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html) – Alex Aug 14 '21 at 12:55
  • If A and B are called from user to input, then it didn't work, please add on this, i'll be grateful. – Kisna Aug 15 '21 at 06:59
  • Sounds like the are strings not integers. – Alex Aug 15 '21 at 10:09

1 Answers1

0

This is simple selection:

df.query('(A==0) & (B==1)')[['C', 'D', 'E']]
mozway
  • 194,879
  • 13
  • 39
  • 75
  • If A and B are called from user to input, then it didn't work, please add on this, i'll be grateful. – Kisna Aug 15 '21 at 07:00