consider the below 2D numpy array
array1 = np.array([[ 0, 1, 2, 3, 4],
[ 5, 21, 15, 8, 12],
[ 2, 3, 4, 8, 3],
[ 3, 4, 5, 17, 41],
[ 4, 20, 7, 5, 6]])
my desired output is to shift the array at its diagonal to the left and pad the empty elements with np.nan
desired output
array([[ 0., 1., 2., 3., 4.],
[21., 15., 8., 12., nan],
[4., 8., 3., nan, nan],
[17., 41., nan, nan, nan],
[6., nan, nan, nan, nan]])
how can i achieve this?