lundi 1 novembre 2021

Creating multiple dataframes and saving them on Excel

I would like to create multiple dataframes containing four columns of random numbers and save them as separate Excel files. I am unable to achieve that, though I know it has something to do with the for loop. I appreciate any help in regards this. My code is as follows:

import random
import numpy as np

locus_list=['0 to +15','+15 - +30', '+45 - +60','+60 - +75','+75 - +90','-30 - -45', '-45 - -60','-60 - -75', '-75 - -90'];
heights_list=[8, 11, 14, 17, 20, 23, 26, 29, 32];


random_heights_list =random.choices(heights_list, k=9)
print(random_heights_list);


Surface_selection=['yes','no'];
Surface_selection_list =np.array(random.choices(Surface_selection, k=9))
print(Surface_selection_list);

import pandas as pd

df = pd.DataFrame(list(zip(locus_list,random_heights_list,Surface_selection_list,Surface_selection_list)),index=['1','2','3','4','5','6','7','8','9'],columns=['Locus position','Building heights (m)', 'Roof selection for SE', 'Facade selection for SE']);
df



Aucun commentaire:

Enregistrer un commentaire