1

I'm working on a rather large excel file and as part of it I'd like to insert two columns into a new excel file at the far right which works, however whenever I do so an unnamed column appears at the far left with numbers in it.

This is for an excel file, and I've tried to use the .drop feature as well as use a new file and read about the CSV files but I cannot seem to apply it here, so nothing seems to solve it.

wdf = pd.read_excel(tLoc)

sheet_wdf_map = pd.read_excel(tLoc, sheet_name=None)


wdf['Adequate'] = np.nan
wdf['Explanation'] = np.nan

wdf = wdf.drop(" ", axis=1)

I expect the output to be my original columns with only the two new columns being on the far right without the unnamed column.

cs95
  • 379,657
  • 97
  • 704
  • 746
Mitchell T
  • 33
  • 7
  • Possible duplicate of [How to get rid of "Unnamed: 0" column in a pandas DataFrame?](https://stackoverflow.com/questions/36519086/how-to-get-rid-of-unnamed-0-column-in-a-pandas-dataframe) – Amit Amola Jun 04 '19 at 13:38
  • @AmitAmola Very similar solution, although that is for CSV files and read_csv. – cs95 Jun 04 '19 at 13:54

1 Answers1

2

Add index_col=[0] as an argument to read_excel.

cs95
  • 379,657
  • 97
  • 704
  • 746