I am trying to turn an excel file into tuples within a list, looking something like this:
numbers = [
(("Gracias"), ("Thank you")),
(("Lo siento"), ("Sorry")),
(("Salud"), ("Bless you")),
(("Sí"), ("Yes")),
]
However, it keeps displaying like 10 different errors when i run the code
import pandas as pd
numfile = pd.read_excel("/Users/jaskeatsingh/Documents/python punjabi/Book2.xlsx")
newnumbers = [(str(row['Number']), str(row['Word'])) for _, row in df.iterrows()]
print(newnumbers)
This is the code that i am trying to run, I have even tried to run the file by just trying to see the first few lines of the excel fiel with head() but that doesnt work either
import pandas as pd
numfile = pd.read_excel("/Users/jaskeatsingh/Documents/python punjabi/Book2.xlsx")
newnumbers = [(str(row['Number']), str(row['Word'])) for _, row in df.iterrows()]
print(newnumbers)
Here are the errors:
File "/Users/jaskeatsingh/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/pandas/compat/_optional.py", line 135, in import_optional_dependency
module = importlib.import_module(name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'openpyxl'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jaskeatsingh/PycharmProjects/pythonProject4/Punjabi Numbers/Testing.py", line 4, in <module>
numfile = pd.read_excel("/Users/jaskeatsingh/Documents/python punjabi/Book2.xlsx")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jaskeatsingh/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/pandas/io/excel/_base.py", line 495, in read_excel
io = ExcelFile(
^^^^^^^^^^
File "/Users/jaskeatsingh/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/pandas/io/excel/_base.py", line 1567, in __init__
self._reader = self._engines[engine](
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/jaskeatsingh/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/pandas/io/excel/_openpyxl.py", line 552, in __init__
import_optional_dependency("openpyxl")
File "/Users/jaskeatsingh/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/pandas/compat/_optional.py", line 138, in import_optional_dependency
raise ImportError(msg)
ImportError: Missing optional dependency 'openpyxl'. Use pip or conda to install openpyxl.
New contributor
Singh Jaskeat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.