Pandas > Save & load data from Excel file

Name
Code
Output
# requires instaled Python openpyxl module
# create dataframe
dataframe = pandas.DataFrame(numpy.random.randint(0,100,size=(5, 4)), columns=['C1','C2','C3','C4'])
print ("dataframe")
print (dataframe)
# save dataframe to Excel
dataframe.to_excel('dataframe.xlsx',sheet_name='sheet01')
# list directory
for entry in os.scandir('.'):
    print(entry.name)
# load dataframe from csv
loaded_dataframe = pandas.read_excel('dataframe.xlsx',sheet_name='sheet01')
print ("loaded dataframe")
print (loaded_dataframe)
dataframe
   C1  C2  C3  C4
0  81  13  27  17
1  58   0  44  94
2  19   0  49  87
3  12  56  93  53
4  47  92  10  11
dataframe.xlsx
loaded dataframe
   C1  C2  C3  C4
0  81  13  27  17
1  58   0  44  94
2  19   0  49  87
3  12  56  93  53
4  47  92  10  11