I want to read the data on an excel file within a F drive. I am using python on Visual Studio Code to try achieve this however I am getting an error as seen in the pictures below. I installed pandas but I still get an error. How can I fix this issue?
I tried closing and opening visual studio. I tried uninstalling and reinstalling pandas.
2
Answers
You should try to open terminal in VS Code, and run
pip freeze
(andpip3 freeze
). Check if you find pandas in the results, it won’t. That must be because you’d have multiple installations of Python on your system. You may do any one of the below –To read an Excel file with Python, you need to install the pandas library. To install pandas, open the command line or terminal and type:
pip install pandas
Once pandas is installed, you can read an Excel file like this:
import pandas as pd
df = pd.read_excel(‘file_name.xlsx’)
print(df)
You should also make sure that the file path is correct and that you have the correct permissions to access the file.
If you are still having issues, try using the absolute file path instead of a relative file path.