0

I'm new to python and have the following code:

T_0 = 288.15
def theta(OT, T_0):
   return (273.15+OT)/(T_0)
Temp = []
for i in range (len(gp_data_list)):
   temp = [] 
   for ot in gp_data_list[i]["OAT"]:
       temp.append(theta(ot, T_0))
   Temp.append(temp)
Temptp = np.transpose(Temp)
Temptable = pandas.DataFrame(Temptp, columns = [Table_header])
print (Temptable)
print (Int_del)

Which returns the following (image link below is a bit clearer):

    Group A   Group B   Group C   Group D   Group E   Group F   Group G  \
0  0.958355  0.958355  0.965296  0.961825  0.951414  0.958355  0.947944   
1  0.961825  0.961825  0.968766  0.965296  0.954885  0.961825  0.951414   
2  0.965296  0.961825  0.972237  0.965296  0.954885  0.965296  0.951414   
3  0.965296  0.961825  0.968766  0.965296  0.951414  0.961825  0.947944   
4  0.965296  0.965296  0.972237  0.965296  0.954885  0.965296  0.947944   
5  0.965296  0.965296  0.968766  0.961825  0.954885  0.965296  0.947944   
6  0.968766  0.961825  0.968766  0.961825  0.954885  0.968766  0.944473   
7  0.968766  0.965296  0.968766  0.965296  0.958355  0.968766  0.947944   

    Group H   Group I   Group J   Group K   Group L   Group M   Group N  
0  0.958355  0.965296  0.944473  0.951414  0.951414  0.944473  0.961825  
1  0.961825  0.968766  0.944473  0.954885  0.951414  0.944473  0.965296  
2  0.965296  0.968766  0.947944  0.954885  0.954885  0.947944  0.965296  
3  0.961825  0.968766  0.947944  0.951414  0.954885  0.947944  0.961825  
4  0.961825  0.965296  0.947944  0.954885  0.958355  0.947944  0.965296  
5  0.958355  0.965296  0.947944  0.954885  0.954885  0.947944  0.961825  
6  0.958355  0.961825  0.947944  0.951414  0.954885  0.947944  0.958355  
7  0.961825  0.965296  0.951414  0.954885  0.951414  0.944473  0.961825  


[0.850848, 0.818776, 0.849304, 0.817502, 0.83068, 0.896331, 0.799865, 0.860208, 0.894374, 0.738814, 0.766681, 0.766681, 0.73902, 0.385863]

https://i.stack.imgur.com/YgoPy.png

I would like to multiply every value in column A by the first value in the list (0.850848), column B by the second value in the list etc, but I have no idea how to do so - any guidance on what to do would be much appreciated

Jmmmm62
  • 13
  • 2
  • Welcome to SO. This isn't a discussion forum or tutorial. Please take the [tour] and take the time to read [ask] and the other links found on that page. Pandas documentation is pretty good. Start with the [Getting Started section](https://pandas.pydata.org/docs/getting_started/index.html#getting-started) then go on to the [User Guide](https://pandas.pydata.org/docs/user_guide/index.html). – wwii Jun 15 '20 at 23:13
  • Did you try `Temptable * Int_del` ? – wwii Jun 15 '20 at 23:18
  • Related: [How do I operate on a DataFrame with a Series for every column](https://stackoverflow.com/questions/53217607/how-do-i-operate-on-a-dataframe-with-a-series-for-every-column). – wwii Jun 15 '20 at 23:22
  • Does this answer your question? [Multiply entire columns with values in a list](https://stackoverflow.com/questions/56921182/multiply-entire-columns-with-values-in-a-list) – wwii Jun 15 '20 at 23:23
  • [Formatting help](https://stackoverflow.com/editing-help)... [Formatting sandbox](https://meta.stackexchange.com/questions/3122/formatting-sandbox) – wwii Jun 15 '20 at 23:25

2 Answers2

1

a.multiply([2,3], axis='rows') or a.multiply([2,3], axis='columns')

Frank
  • 459
  • 2
  • 9
0

Can you try this?

Temptable *= np.array(Int_del)

XXavier
  • 1,206
  • 1
  • 10
  • 14