Convert CSV to Excel using Pandas in Python
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:

import pandas as pdimport numpy as np # Reading the csv filedf_new = pd.read_csv('Names.csv') # saving xlsx fileGFG = pd.ExcelWriter('Names.xlsx')df_new.to_excel(GFG, index = False) GFG.save() |
Output:

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course


