Assuming that I have three Series objects with the same length and containing float64 elements how to create another Series object (also with the same length) which will contain maximum values from those three Series? Is there a nifty way (instead of just writing for loop and comparing each three elements and append each maximum to collection) to do it in numpy?
You can use the nanmax method :
s1 = [1,3,4]
s2 = [1,4,6]
s3 = [np.nan,5,3]
np.nanmax([s1,s2,s3], axis = 0)
[out]: array([ 1., 5., 6.])
nanmax
is safer over max
since it handles NaN
values
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.