How to name dataframe using a list of inputs
I have many wells, every well belongs to some branch and then a few branches together creates a field. I use cycle to do the same operation for every well
items=['1','5','8','22','2']
for item in items
well=item
......
This cycle loads data from database, cleans it, calculates for each well rates, pressures etc. This cycle also creates plots and writes output data results to excel file which contains sheets with names 1,5,8,22,2. But then I have to summ rates, pressures etc. for branches, and then to summ branches to field.
Is there a way to name a resulting dataframe using this item well name list too?
Because currenlty for branches I have write by hands:
well1=pd.read_excel('results.xlsl ', sheet_name='1')
well5=pd.read_excel('results.xlsl ', sheet_name='1')
branch['rate']=well1['rate']+well5['rate']
etc.
Instead of creating separate DataFrame variables for each well (like well1, well5, etc.), you can store them in a dictionary where each key is the well name (or number) and the value is the corresponding DataFrame. This way, you can easily access and manipulate data for each well using its name as a key.
Example in py:
Once you have your well DataFrames in a dictionary, you can aggregate this data for branches and fields.
Example of aggregating data for branch:
This way You'll define which wells belong to which branches, and then perform your calculations (e.g., summing rates, pressures) by accessing the relevant DataFrames from your dictionary.