Created
September 22, 2017 15:52
-
-
Save EdMan1022/e7018fb7c6222448580c6af37d3c0157 to your computer and use it in GitHub Desktop.
Pandas dataframe to txt file with comma delimiter test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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