Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Convert CSV to Excel using Pandas in Python

  • Difficulty Level : Easy
  • Last Updated : 02 Jul, 2020

Pandas can read, filter, and re-arrange small and large datasets and output them in a range of formats including Excel. In this article, we will be dealing with the conversion of .csv file into excel (.xlsx).

Pandas provide the ExcelWriter class for writing data frame objects to excel sheets.
Syntax:

final = pd.ExcelWriter('GFG.xlsx')

Example:

Sample CSV File:

python-csv-to-json




import pandas as pd
import numpy as np
  
  
# Reading the csv file
df_new = pd.read_csv('Names.csv')
  
# saving xlsx file
GFG = pd.ExcelWriter('Names.xlsx')
df_new.to_excel(GFG, index = False)
  
GFG.save()

Output:

python-csv-to-excel

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!