I have a Series like this:
s = pd.Series({10: np.array([[0.72260683, 0.27739317, 0. ],
[0.7187053 , 0.2812947 , 0. ],
[0.71435467, 0.28564533, 1. ],
[0.3268072 , 0.6731928 , 0. ],
[0.31941951, 0.68058049, 1. ],
[0.31260015, 0.68739985, 0. ]]),
20: np.array([[0.7022099 , 0.2977901 , 0. ],
[0.6983866 , 0.3016134 , 0. ],
[0.69411673, 0.30588327, 1. ],
[0.33857735, 0.66142265, 0. ],
[0.33244109, 0.66755891, 1. ],
[0.32675582, 0.67324418, 0. ]]),
20: np.array([[0.68811957, 0.34188043, 0. ],
[0.68425783, 0.31574217, 0. ],
[0.67994496, 0.32005504, 1. ],
[0.34872593, 0.66127407, 1. ],
[0.34276171, 0.65723829, 1. ],
[0.33722803, 0.66277197, 0. ]]),
38: np.array([[0.68811957, 0.31188043, 0. ],
[0.68425783, 0.31574217, 0. ],
[0.67994496, 0.32005504, 1. ],
[0.34872593, 0.65127407, 0. ],
[0.34276171, 0.65723829, 1. ],
[0.33722803, 0.66277197, 0. ]]),
np.nan: np.nan}
)
I want to subset it with np.array([1, 4, 1, 5])
or np.array([1, 4, 1, np.nan])
returning np.nan
no matter what the value is on the last element of indices array. How can I accomplish that?
Please note that I can't simply remove last element of a Series.