1

Here's some data from another question:

main    Meas1     Meas2 Meas3   Meas4  Meas5
sublvl  Value     Value Value   Value   Value       
count   7.000000  1.0   1.0     582.00  97.000000       
mean    30        37.0  26.0    33.03   16.635350

I would like to read in this data in such a way that the first column is actually the index, and the first two rows are treated as multi-level columns where MeasX is the first level, and Value is the second level.

How can I do this using pd.read_clipboard?


My pd.read_clipboard series:

cs95
  • 379,657
  • 97
  • 704
  • 746

1 Answers1

6
In [17]: pd.read_clipboard(sep='\s+', index_col=[0], header=[0,1])
Out[17]: 
main   Meas1 Meas2 Meas3   Meas4     Meas5
sublvl Value Value Value   Value     Value
count    7.0   1.0   1.0  582.00  97.00000
mean    30.0  37.0  26.0   33.03  16.63535
unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677
  • What really amazes me about this answer is how close I came to it: `pd.read_clipboard(index=[0], header=[1, 2])` – cs95 Aug 21 '17 at 15:18
  • Probably because of all the other dumb mistakes, such as `index` instead of `index_col`, and not specifying sep... etc etc. I have a lot to learn. – cs95 Aug 21 '17 at 15:26