0

The dataframes in Pandas contain column name and row name.How can I stop outputting the row name? I have found method called itertuples where you can set the index to False but that does not seem to work.

The input is a csv file and the output is a xlsx file with sheets. Each sheet contains row numbers right now but those need to disappear.

See comments for answer. This worked for me:

PandasDataFrame.to_excel(PandasWriter, sheet_name='Source', index=False)
Adrian Z.
  • 904
  • 1
  • 12
  • 29
  • Why is this a problem? what are you trying to achieve? – EdChum Feb 15 '16 at 13:28
  • I just don't want the row numbers in my output. That's all. I'm converting a csv file into a xlsx file and the output needs to be according to a predefined template. – Adrian Z. Feb 15 '16 at 13:30
  • @Andy that will output a very long string which is not what the OP is after, they want their output to just pretty print the values only without index values – EdChum Feb 15 '16 at 13:35
  • I'm trying Andys suggestion but that does not seem to work for me. Printing to a string is not an option just as EdChum stated. – Adrian Z. Feb 15 '16 at 13:37
  • I see that Andy has disappeared. He's answer was actually semi-right. The answer from http://stackoverflow.com/questions/24644656/how-to-print-dataframe-without-index is not exactly right but the method to_string has similar attributes as method that I have to use to_excel. The following works for me "PandasDataFrame.to_excel(PandasWriter, sheet_name='Source', index=False)". Thanks @Andy. – Adrian Z. Feb 15 '16 at 13:46

1 Answers1

0

The following worked for me (from the comments):

PandasDataFrame.to_excel(PandasWriter, sheet_name='Source', index=False)

Adrian Z.
  • 904
  • 1
  • 12
  • 29