I have a data frame with many columns and three rows. I want to filter for the columns based on conditions for different rows
e.g. In the following example I would like to get all the columns for which row 'AAA' has a value of < -1 and for which rows 'BBBB' and 'CCCC' have a value of > -1
import pandas as pd
data = {"Name": ["AAAA", "BBBB", "CCCC"],
"C1": [-2, -0.5, -0.5],
"C2": [-2, -0.5, -0.5],
"C3": [-0.5, -2, -2]}
df = pd.DataFrame(data)
df.set_index("Name")
C1 C2 C3
Name
AAAA -2.0 -2.0 -0.5
BBBB -0.5 -0.5 -2.0
CCCC -0.5 -0.5 -2.0
I think I need to use loc but I don't know how in this case.
My output would ideally be:
C1 C2
Name
AAAA -2.0 -2.0
BBBB -0.5 -0.5
CCCC -0.5 -0.5