I have a data frame DF
as follows:
import pandas as pd
DF = pd.DataFrame({'A': [1], 'B': [2]})
I'm trying to save it to a Test.txt
file by following this answer, with:
np.savetxt(r'Test.txt', DF, fmt='%s')
Which does save only DF
values and not the column names:
1 2
How do I save it to have Test.txt
with the following contents?
A B
1 2