pydata/pandas — pull request #6170 by waitingkuo (2014-01-29 15:47:23+00:00)
Title: Fix issue 6051

Bug: `mangle_dupe_cols` cannot work while the header is a list.

Originally, `has_mi_columns` will be set as 1 while the header is a list. And the `mangle_dupe_cols` things would not work when `has_mi_columns` == 1.

This pull request is to

1. for the list with single element, for example [0], the `has_mi_columns` will be set as 0, and the header will do the original `mangle_dupe_cols` things as the header is a single integer.
2. for the list with more than one element, append the sequence number in the last element of the duplicated multi-column

For example

Male,Male,Male,Male,Male,Female,Female
A,B,B,B,C,D,D
1,2,3,4,5,6,7
1,2,3,4,5,6,7
1,2,3,4,5,6,7
1,2,3,4,5,6,7
1,2,3,4,5,6,7
1,2,3,4,5,6,7

would be converted to

In [2]: pd.read_csv('woo.csv', header=[0,1])
Out[2]:
Male Female
A B B.1 B.2 C D D.1
0 1 2 3 4 5 6 7
1 1 2 3 4 5 6 7
2 1 2 3 4 5 6 7
3 1 2 3 4 5 6 7
4 1 2 3 4 5 6 7
5 1 2 3 4 5 6 7

[6 rows x 7 columns]