Use “to_csv” and “to_excel” methods to save pandas dataframe to csv and excel file respectively

# Imports 
import pandas as pd

# Let's create a pandas dataframe
df = pd.DataFrame({"Name": ['Joyce', 'Joy', 'Ram', 'Maria'], 
                   "Age": ['19', '18', '20', '19']}, columns = ['Name', 'Age'])

print("Created dataframe: \n{}".format(df))
Created dataframe: 
    Name Age
0  Joyce  19
1    Joy  18
2    Ram  20
3  Maria  19
# Saving to a csv file
df.to_csv('students.csv')
# Saving to an excel file with sheet name
df.to_excel('students.xlsx', sheet_name='computer class')