I have the following Data frame:
In [18]: import pandas as pd
In [32]: df = pd.DataFrame.from_items([("A\tbar", [1, 2, 3]), ("B\tfoo" , [4, 5, 6])],orient='index', columns=['one', 'two', 'three'])
In [33]: df
Out[35]:
one two three
A\tbar 1 2 3
B\tfoo 4 5 6
In [34]: df.to_csv("tmp.csv" , sep='\t', encoding='utf-8', doublequote=False)
The final written file looks like this (note the double quote in row name still exist too, we'd like to remove that):
In [34]: !cat tmp.csv
one two three
"A bar" 1 2 3
"B foo" 4 5 6
What I want to do is to name the columns of the row names that looks like this in the final created file (tmp.csv):
alpha othername one two three
A bar 1 2 3
B foo 4 5 6
What's the way to do it?
row namesas another column, how do I exclude row names from being printed out? It'll be great if you can guide with example code.index=Falsetoto_csv.