The student question came into class regarding column headers in pandas. His specific question came about because he was adding column headers to his code, but they were being coerced into strings. df=pd.DataFrame(index=['x','y'], data={'a':[1,2],'b':[3,4]}) will produce c1 c2 x 1 a x 3 b y 2 a y 4 b To convert column names into values: Unstack print (df.T.unstack().reset_index(level=1, name='c1') .rename(columns={'level_1':'c2'})[['c1','c2']]) c1 c2 x 1 a x 3 b y 2 a y 4 b ================ Or: Stack print (df.stack().reset_index(level=1, name='c1') .rename(columns={'level_1':'c2'})[['c1','c2']]) c1 c2 x 1 a x 3 b y 2 a y 4 b =============== OR Melting: (pd.melt(df.reset_index(), var_name='c2', value_name='c1', id_vars='index') .set_index('index')) c2 c1 index x a 1 y a 2 x b 3 y b 4 ================ EVEN: HTML!!! (add this to code above to bring in the df object) from IPython.display import display, HTML display(HTML(df.to_html())) ============== Tabulate ***Tablulate is a python download package. Get it here: https://pypi.org/project/tabulate/ Info on installing packages into Jupyter: https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/ Code to use tabulate: from tabulate import tabulate import pandas as pd df = pd.DataFrame({'col_two' : [0.0001, 1e-005 , 1e-006, 1e-007], 'column_3' : ['ABCD', 'ABCD', 'long string', 'ABCD']}) print(tabulate(df, headers='keys', tablefmt='psql')) ===================== LASTLY: Use import csv method? import csv import os inputFileName = "test.csv" outputFileName = os.path.splitext(inputFileName)[0] + "_modified.csv" headersDict = {'NUMBER, SEX AND AGE - Total Population - Under 5 years': 'TPop00_05', 'NUMBER, SEX AND AGE - Total Population - 5 to 9 years': 'TPop05_09', 'NUMBER, SEX AND AGE - Total Population - 10 to 14 years': 'TPop10_14', 'NUMBER, SEX AND AGE - Total Population - 15 to 19 years': 'TPop15_19', 'NUMBER, SEX AND AGE - Total Population - 20 to 24 years': 'TPop20_24', 'NUMBER, SEX AND AGE - Total Population - 25 to 29 years': 'TPop25_29' } with open(inputFileName, 'rb') as inFile, open(outputFileName, 'wb') as outfile: r = csv.reader(inFile) w = csv.writer(outfile) # read the first row from the reader, the old header header = next(r) print header # replace items in header using dictionary, if item not in dictionary, it will not be replaced newHeader = [ headersDict.get(item,item) for item in header ] print newHeader # write new header w.writerow(newHeader) # copy the rest for row in r: w.writerow(row) ======================= Final Thought: ****A great example of displaying. https://github.com/ShikhaChm/Python_HeroesOfPymoli