Python Practice › Pandas Programs › Program 95

Import an Excel file

EasyPandas Programs · 95 of 95

Write a pandas program to import an .xlsx file.

Advertisement
Output
   name  marks
0  Asha     91
1  Ravi     78

Approach

  1. pd.read_excel (needs openpyxl installed).

Solution

Python
import pandas as pdpd.DataFrame({"name": ["Asha", "Ravi"], "marks": [91, 78]}).to_excel("marks.xlsx", index=False)df = pd.read_excel("marks.xlsx")print(df)
Output
   name  marks
0  Asha     91
1  Ravi     78
Note

Install openpyxl first with python -m pip install openpyxl. The browser Try it does not include it.

Learn the concept

New to this topic? Read the lesson, then come back.

More pandas programs

← All 95 Pandas Programs

Leave a Comment