I have a simple question. I have a small dataframe:
Column1 Column2 Column3
Row1 0 4 6
Row2 1 3 5
Row3 0 4 2
I need to only print out only Column1 and Column2 only if Column1 equals 1:
Column1 Column2
Row2 1 3
I have this piece of code that I am stuck at:
col=[col for col in df.columns if col=="Column1" or col=="Column2"]
print(loc[:,col])
This is printing out the result such that we are having Column1 and Column2 with all the values.
Column1 Column2
Row1 0 4
Row2 1 3
Row3 0 4
How can I incorporate the condition such that Column1==1?
Thanks!