Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 656

How to merge Headers of index and other headers to one row of headers and add numeric index as single index [duplicate]

$
0
0

I currently have this type of a df with 2 headers

        client case  client payment  payment numberclient  foo            1             200               1boo            1             250               2moo            1             225               3

and I would like a numeric index and merge the header into one single header and for the previous index to be the first column:

  client  client case  client payment  payment number0  foo            1             200               11  boo            1             250               22  boo            1             225               3

df.columns = [c[0] + c[1] for c in df.columns]this did not work for me, nor dit several set_index options


Viewing all articles
Browse latest Browse all 656

Trending Articles