I am working on a database where there are 6 columns: Economy, ADB Code, Year, Sector, Employment index, VA index. In rows, there are all the countries with values in corresponding years. The problem is that I need to create a new row sector, which will consist of a sum of other sectors. Here's an example in excel
I have tried calculating values for the indexes, and I think that it was successful. Here's the code:
construction = df.query("Sector == 'Construction'")
manufacturing = df.query("Sector == 'Manufacturing'")
mining_utilities = df.query("Sector == 'Mining, Utilities'")
#turning the dataframes from aboove into numpy arrays to calculate the values more easily
construction_array = construction.to_numpy()
manufacturing_array = manufacturing.to_numpy()
mining_utilities_array = mining_utilities.to_numpy()
#calculating values for the new variable
industry_array = construction_array + manufacturing_array + mining_utilities_array
industry_array
The problem is that I don't know how to properly integrate this array into the database since I am lacking values for all the other columns.
I have also tried to do this using dictionaries, but it turned to be confusing, so I decided not to proceed with that option