I have a dataframe
import pandas as pd
df = pd.DataFrame([[1, 2], [3, 4]], columns=['a', 'b'])
I want to write df
to a csv file but not using the columns ['a', 'b']
. The first line is my custom string and the rest are the content of df.values
. For example:
numrows numcols note
1 2
3 4
Can I do this with pandas or I have to manually loop through the content and write to file?