Q:

duplicate a single column with several names in Pandas

I need to clean up a data set, where some columns (read from .csv file) may have several names, listed with commas.  
I need to do the following in pandas:

Any nice pandasian tricks for that? 
Here is a simple code:
import pandas as pd
import numpy as np

df = pd. DataFrame(data=np.random.random(size=(5,6)), 
                  columns={'a', 'b', 'c, d', 'e', 'f, g', 'h'})

df=
          a         b      c, d         e      f, g         h
0  0.771418  0.371685  0.072876  0.153071  0.169513  0.399769
1  0.667551  0.886779  0.949341  0.869588  0.226275  0.273370
2  0.768456  0.945822  0.167757  0.584886  0.328152  0.246415
3  0.354713  0.690585  0.027916  0.237110  0.875449  0.430142
4  0.590518  0.819043  0.803876  0.909385  0.382452  0.867369

I need:
df_new = 

          a         b         c         d         e         f         g         h
0  0.771418  0.371685  0.072876  0.072876  0.153071  0.169513  0.169513  0.399769
1  0.667551  0.886779  0.949341  0.949341  0.869588  0.226275  0.226275  0.273370
2  0.768456  0.945822  0.167757  0.167757  0.584886  0.328152  0.328152  0.246415
3  0.354713  0.690585  0.027916  0.027916  0.237110  0.875449  0.875449  0.430142
4  0.590518  0.819043  0.803876  0.803876  0.909385  0.382452  0.382452  0.867369

UPDATE
And what happens if I have repeated column names:
df = pd. DataFrame(data=np.random.random(size=(5,6)), 
                      columns={'a', 'b', 'c, d', 'c', 'f, g', 'h'})

and the desired results should be
df_new_v2 = 
          a         b         c         d       c.1         f         g         h
0  0.771418  0.371685  0.072876  0.072876  0.153071  0.169513  0.169513  0.399769
1  0.667551  0.886779  0.949341  0.949341  0.869588  0.226275  0.226275  0.273370
2  0.768456  0.945822  0.167757  0.167757  0.584886  0.328152  0.328152  0.246415
3  0.354713  0.690585  0.027916  0.027916  0.237110  0.875449  0.875449  0.430142
4  0.590518  0.819043  0.803876  0.803876  0.909385  0.382452  0.382452  0.867369

A:

You can create first MultiIndex in columns by parameter header and then loop by first level with concat:
df = pd.read_csv(file, header=[0,1])

L = []
cols = df.columns.get_level_values(0)
for x in cols:
    c = df[x].columns.str.split(',')[0]
    a = pd.concat([df[x].squeeze()] * len(c), axis=1, keys=c)
    L.append(a)
df = pd.concat(L, axis=1, keys=cols)

With sample data:
df = pd. DataFrame(data=np.random.random(size=(5,6)), 
                      columns={'a', 'b', 'c, d', 'c', 'f, g', 'h'})

#print (df)
L = []
for x in df.columns:
    c = x.split(', ')
    a = pd.concat([df[x].squeeze()] * len(c), axis=1, keys=c)
    L.append(a)

df = pd.concat(L, axis=1)
s = df.columns.to_series()
df.columns = s + s.groupby(s).cumcount().astype(str).radd('. ').str.replace('.0', '')

print (df)
          c         h         a       c.1         d         b         f  \
0  0.846482  0.285415  0.695800  0.497593  0.497593  0.159911  0.286545   
1  0.195390  0.369074  0.371147  0.102207  0.102207  0.924279  0.349958   
2  0.967811  0.059451  0.942390  0.826203  0.826203  0.722080  0.196833   
3  0.546076  0.789354  0.876819  0.243305  0.243305  0.391054  0.213517   
4  0.311528  0.544023  0.380844  0.308427  0.308427  0.511651  0.795380   

          g  
0  0.286545  
1  0.349958  
2  0.196833  
3  0.213517  

