Thursday, October 18, 2018

How to Read Excel in Python using Pandas

Nowadays the very first python interview question asked by the company is "How to read data from Excel"

In the below example we have an simple example to read the data from excel and show in python.


First, we need to have an excel sheet , in  my case i have below one stored in c:/test/ location


Second, Now we just need Pandas lib to read all data into data frame for which we have code as below.

# importing Panda library and using as 'pd'

import pandas as pd 

#reading excel sheet in data frame in python

df=pd.read_excel("C:\\test\\Data.xlsx")

#Displaying data set 'Top 5 row

df.head()


Output



No comments:

Post a Comment

JOB in 2019

Automated - Digital One o One Meetings- An Idea

                                            Automated - Digital One o One Discussion                                                       ...