Importing Excel Documents into Python

Viewed 56

I just want to import an excel file into python on Jupiter. I have tried everything and looked at multiple Q&A's and nothing has worked. I appreciate any help. This is the code I am using.

import numpy as np
import pandas as pd

'''
Excel_file = pd.ExcelFile('C:\Documents\Accounting\Applied_Accounting_Principles\Exercises\Data_Analytics\')
'''

df = pd.read_excel(Excel_file)
1 Answers

For starters, welcome! :)

I played with Excel on my computer and this seemed to work:

   Excel_file = pd.read_excel(r'C:\Users\Anon\Desktop\testingexcel.xlsx') 

   print(Excel_file)

Output was (for my excel file) :

   Numbers
0        1
1        2
2        3
3        4
4        5

Include the r (this is to "read" the file) before placing the file address, including the file ending with .xlsx, for example r'C:\Users\Ben\Documents\excelfile.xlsx'

If you want to just print columns you can also utilize the pd.DataFrame(Excel_file, columns=['Column Name'])

Let me know if this is what you were looking for.

Related