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
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