dimanche 28 février 2021

Python insert output into new row of existing excel file

I have this simple code to print random numbers. Each time i run this code, the values are being replaced. How do I make it write from the next available row within the same excel file? Thanks.

import pandas as pd
import random
import time
from xlsxwriter import*
from time import time, sleep


numberList = [0, 40, 43, 45, 48, 50, 53, 55, 58, 60]
my_list = []
my_list = (random.choices(numberList, weights=(2, 1, 3, 6, 3, 2, 2, 1, 1, 1), k=100))


df = pd.DataFrame.from_dict({'Random No':my_list})
df.to_excel('dataset5.xlsx', header=True, index=False)



Aucun commentaire:

Enregistrer un commentaire