The median() method can only compute the median for either rows or columns in a single call. You need to call the method twice, once with axis=0 and once with axis=1, to get both row-wise and column-wise medians.