0

I am a super new user of Python and have been having trouble loading an Excel file to play around with in Python.

I am using Python 3.7 on Windows 10 and have tried things like using the import statement or using pip and pip3 and then install statements. I am so confused on how to do this and no links I've read online are helping.

pip install pandas
pip3 install pandas
import pandas

I just want to upload an Excel file into Python. I'm embarrassed that it's causing me this much stress.

10
  • Possible duplicate of Reading an Excel file in python using pandas Commented Aug 2, 2019 at 18:52
  • Did the pip commands complete successfully? Commented Aug 2, 2019 at 18:54
  • when I type in pip import pandas, I get the following message: SyntaxError: invalid syntax pointing toward the t in import Commented Aug 2, 2019 at 18:56
  • Is your import working or are you unaware on how to proceed with ur code? Commented Aug 2, 2019 at 18:56
  • 2
    @user2813606 1.) Open cmd.exe 2.)type python and hit enter 3.)type import pandas and hit enter.. let us know the result Commented Aug 2, 2019 at 19:01

1 Answer 1

1

first of all you have to import pandas (assuming that is installed, in anaconda usually is already installed as far as i know)

import pandas as pd

to read more sheets in different dataframes (tables)

xls = pd.ExcelFile(path of your file)
df_schema = pd.read_excel(xls, sheet_name=xls.sheet_names) 

df_schema is a dictionary of df in which the key is the name of the sheet and the value is the dataframe.

to read a single sheet the following should work:

xls = pd.ExcelFile(path of your file)
df = pd.read_excel(xls) 
Sign up to request clarification or add additional context in comments.

1 Comment

When I type in import pandas as pd, I get the following message: Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'pandas'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.