Source From Here
Question
"How to find the max from each row in python and store it in an numpy array or pandas Dataframe and store it in an numpy array , i.e the output below"
HowTo
Use the numpy amax function. np.amax:
which returns:
- 0.511474 0.488526
- 0.468783 0.531217
- 0.35111 0.64889
- 0.594834 0.405166
HowTo
Use the numpy amax function. np.amax:
- import numpy as np
- a = np.array([[0.511474, 0.488526],
- [0.468783, 0.531217],
- [0.35111, 0.64889],
- [0.594834, 0.405166]])
- x = np.amax(a, 1)
- print(x)
沒有留言:
張貼留言