How to read columns from excel file in Python

You can read the columns from excel file in Python with the following code. I highly recommend you This book to learn Python.

Read columns from excel file

# Import the Pandas library as pd
import pandas as pd

# Select columns which you want to read
columns = ["Area", "Price"]

# Read specific columns from Excel file
df = pd.read_excel("house_price.xlsx", usecols=columns)

# Display the Data
print(df)

Output:

   Area  Price
0  5000  75000
1  4000  65000
2  3000  60000
3  2000  58000
4  1500  50000
5  7000  90000
6  6000  85000
7  6500  80000
8  8000  95000

Free Learning Resources

Leave a Comment

Your email address will not be published.