Pandas > Save & load data from CSV file

Name
Code
Output
# 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 csv
dataframe.to_csv('dataframe.csv')
# list directory
for entry in os.scandir('.'):
    print(entry.name)
# load dataframe from csv
loaded_dataframe = pandas.read_csv('dataframe.csv',index_col=0)
print ("loaded dataframe")
print (loaded_dataframe)
dataframe
   C1  C2  C3  C4
0  98  82  43  95
1  61  76  19  42
2   3  59  27  40
3  88  13  36  45
4  29  12  43  24
dataframe.csv
loaded dataframe
   C1  C2  C3  C4
0  98  82  43  95
1  61  76  19  42
2   3  59  27  40
3  88  13  36  45
4  29  12  43  24