0

I can't find solution for my problem. I have two vectors pandas.Series type T = [a1, a2, a3,....,an] M = [b1, b2, b3,...bn] I need to create new vector in which every element should be the minimum between two elements in the given vector. It should looks like new_vector = [min(a1, b1), min(a2, b2), ....min(an, bn) Is this possible with the functions in pandas?

m_m
  • 1
  • 1

1 Answers1

0

Yes, can use pandas min() function to return lowest value per element position

Minimum Value Comparing Each Element of Pandas Series

import pandas as pd
T = pd.Series([6,7,4,1,4,1,6,8,0])
M = pd.Series([5,3,8,1,3,7,1,7,1])

new_vector = pd.DataFrame([T,M]).min()
print(new_vector)

Results:

idx  minValue
0    5
1    3
2    4
3    1
4    3
5    1
6    1
7    7
8    0
Stephan
  • 5,891
  • 1
  • 16
  • 24