Skip to content

Instantly share code, notes, and snippets.

@EdMan1022
Created September 22, 2017 15:52
Show Gist options
  • Save EdMan1022/e7018fb7c6222448580c6af37d3c0157 to your computer and use it in GitHub Desktop.
Save EdMan1022/e7018fb7c6222448580c6af37d3c0157 to your computer and use it in GitHub Desktop.
Pandas dataframe to txt file with comma delimiter test
import pandas as pd
# Pandas dataframe to txt file with comma delimiter test
df = pd.DataFrame(index = [0,1,2,3,4])
df.loc[:, 'a'] = 'a'
df.loc[:, 'b'] = 2
df.loc[:, 'c'] = ' '
df.loc[:, 'd'] = None
df.loc[:, 'e'] = 'e'
df.loc[:, 'f'] = ''
df.loc[:, 'h'] = 23
df.to_csv("test.txt", header=None, index=None, sep=',', mode='w')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment