0

I use the following code to print a dataframe into a csv file based on the answers seen at this question: How to avoid Python/Pandas creating an index in a saved csv?

y_insincere = [classify_text(text,trimmed_posterior_dict)<0 for text in X_test]
X_output = pd.DataFrame() 
X_output['number'] = number
X_output['CASE'] = case
X_output.to_csv('submission.csv',header=True,columns = ['id','case'],index='False')

However, when I look at the csv file it has an extra column without a header with row indices. I tried other fixes from the above question, but nothing worked. I am stuck. Any help appreciated

CJR
  • 3,916
  • 2
  • 10
  • 23
Arun
  • 180
  • 11
  • `X_output.to_csv('submission.csv',header=True,columns = ['id','case'],index=False)` `'False'` is not `False` in pandas – BENY Nov 20 '18 at 22:18
  • @W-B Oops.That must be the error. Thank you! Wonder why it didn't throw an error. – Arun Nov 21 '18 at 08:16

0 Answers0