0

Like the data here, if I have more than one header, how can we read the specific column that I want, thanks!

       machine A       A       B
       date    12-01  12-02   12-01
       number  #1      #2      #2
              0.223   0.224   0.226
              0.333   0.444   0.234
              0.234   0.124   0.456    
1
  • 1
    What is the issue, exactly? Please see How to Ask, help center. Commented Apr 23, 2020 at 21:44

1 Answer 1

2

You have to use the xs function: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.xs.html

For exemple

print(df.xs('A', level='machine', axis=1)) 

Or

print(df.xs('#1', level='number', axis=1)) 
Sign up to request clarification or add additional context in comments.

Comments

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.