Pandas get the minimum value of two columns as part of the equation

How can I refer to the minimum value of two data frames as part of the pandas data frame equation? I tried using the python min() function which did not work. Sorry if this is somewhere well documented, but I could not find a working solution for this problem. I am looking for something like this:

 data['eff'] = pd.DataFrame([data['flow_h'], data['flow_c']]).min() *Cp* (data[' Thi'] - data[' Tci']) 

I also tried using the pandas min() function, which also does not work.

 min_flow = pd.DataFrame([data['flow_h'], data['flow_c']]).min() InvalidIndexError: Reindexing only valid with uniquely valued Index objects 

I was confused by this mistake. Data columns are just numbers and a name, I was not sure where the index comes into the game.

 In [108]: data['flow_c'] Out[108]: 0 74.014640 1 74.150579 2 74.014640 3 73.960195 4 74.069046 5 73.960195 6 73.987423 7 73.905710 
+5
source share
1 answer

Your question is not very clear to me, but I assume that you are trying to get an elementary mininum from two Series (not DataFrame s). If you want, try: data[['flow_h','flow_c']].min(axis=1) .

+11
source

Source: https://habr.com/ru/post/1237016/


All Articles