how to write a dataframe into a txt file in python code example Example: save df to txt df.to_csv(r'c:\data\pandas.txt', header=None, index=None, sep='\t', mode='a')