I'm using Numpy to calculate somme formulas. I need a datafrale results with more details.
I tried something like df_append.append to load data in dataframe.
df_cars = pd.DataFrame(data= None,['CarName', "ModelName",'Month', 'values'])
for(carname in cars):
modelsnames = getModels(car)
for(modelname in Models):
values=np.array(get_values(car,model))
#values = [1,5,6,9,10,2,10,7,23,90,102,14]
new_row={'CarName' :carname ,"ModelName": modelname, 'Month':np.arange(1,len(index)+1), 'value':index}
df_cars = df_cars.append(new_row, ignore_index=True)
But numpy values save it in one cell(results of Numpy formula)
Example:
numpy values_BMW_Serie1 : [45000,44000,41000,45000,42000]
Car Model Month value
1 BMW Serie1 1 [45000,44000,41000,45000,42000]
I need to save each numpy value in one cell
Car Model Month value
1 BMW Serie1 1 45000
2 BMW Serie1 2 44000
3 BMW Serie1 3 41000
4 BMW Serie1 4 45000
5 BMW Serie1 5 42000
df_cars = df_cars.explode('value'). However, why are you looping to populate your dataframe instead of dumping all the data and filtering once it is part of the df? this way you bypass the loops and the many calls togetModelsandget_values