0

Trying to merge to excel files into single xls. I tried this:

import pandas as pd

excel1 = 'C:/Users/gopoluri/Documents/book1.xlsx'
excel2 = 'C:/Users/gopoluri/Documents/book2.xlsx'
df1 = pd.read_excel(excel1)
df2 = pd.read_excel(excel2)

values1 = df1[0:7]
values2 = df2[0:7]

dataframes = [values1, values2]

join = pd.concat(dataframes, sort=False)
join.to_excel("output.xlsx")

In my data set I am having date in both the excel sheets after concatenating those got replaced with ########

Anyone please help me to fix this.

P.goutham
  • 51
  • 6
  • Does this answer your question? [No module named 'openpyxl' - Python 3.4 - Ubuntu](https://stackoverflow.com/questions/34509198/no-module-named-openpyxl-python-3-4-ubuntu) – vestland Apr 08 '20 at 06:44
  • It seems you are missing the package `openpyxl`. – Ala Tarighati Apr 08 '20 at 06:45

2 Answers2

0

The error you are facing is that the module named openpyxl is not found hence you can install that module using Python package manager pip.

Run the command

pip install openpyxl

which would install the openpyxl and run the python file again.

enter image description here

Community
  • 1
  • 1
0

goutham, Because of my low Reputation score I am unable to comment on your post, that's why I am answering the query, there is nothing wrong in the code part(considering there is no mistake in your dataset, if possible please attach a screenshot of your dataset) so from your error sheet I guess you have to install the "openpyxl" library, you can do it as shown below:

sudo apt-get install python-openpyxl
sudo apt-get install python3-openpyxl

Hope my answer solves your query, Thank you.

megh_sat
  • 374
  • 2
  • 12
  • thank you.. I have installed openpyxl. But now I am getting an extra index column how to remove that. – P.goutham Apr 08 '20 at 07:06
  • Hi Gautham, Whenever you're concatenating you will get an extra index column, in order to prevent the happening you can either "Drop the column" or you can follow the below code snippet while using "contact function": join = pd.concat(dataframes, ignore_index=True) Hope this solves your Query Thank you.. – megh_sat Apr 09 '20 at 05:10