0

I have a dataframe (df):

    a   b   c   d
0   G1  G2  G3  G4
1   1   2   3   4

I'd like to get the whole column data based on certain cell index (0) and cell content (G3) value:

input:

search("G3", df, 0)

output something like:

["c", "G3", 3]

How would you do that?

1 Answer 1

1

I suggest that you can transpose your dataframe first and then do some simple compares:

In [14]: df.T[df.T[0] == 'G3']
Out[14]: 
    0  1
c  G3  3
Sign up to request clarification or add additional context in comments.

1 Comment

Nice! How do you reach name c in this example? I get some object, and can't figure out go further... df.T[df.T[0] == 'G3'][0..3][0] seems to work for cells...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.