Issue
I have the following matrix in pandas:
import numpy as np
import pandas as pd
df_matrix = pd.DataFrame(np.random.random((10, 10)))
I need to get a vector that contains 10 median values, 1 value across each blue line as shown in the picture below:
The last number in the output vector is basically 1 number rather than a median.
Solution
X = np.random.random((10, 10))
fX = np.fliplr(X) # to get the "other" diagonal
np.array([np.median(np.diag(fX, k=-k)) for k in range(X.shape[0])])
Answered By - fiphrelin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.