For a Pandas Series:
ser = pd.Series([i**2 for i in range(9)])
print(ser)
0 0
1 1
2 4
3 9
4 16
5 25
6 36
7 49
8 64
dtype: int64
The median can be grabbed with ser.median()
, which returns 16
. How can the N entries around the median be grabbed? Something like:
print(ser.get_median_entries(3)) # N == 3; not real functionality
3 9
4 16
5 25
dtype: int64