Closed
Description
Is your feature request related to a problem? Please describe.
The Series.map() function should enable the usage of index in the passed lambda, just like the normal Array.map() function does. My example use case is calculating a moving average, which requires referencing values next to the current position in the Series.
Describe the solution you'd like
I would like to be able to write this (which I initially tried to, and had to track down the reason it wasn't working, until I realized the internal map() just doesn't use or provide an index)
df[column].map((val, i) => {
if (i < 5) return 'N/A'
return df[column].iloc([`${i - 5}:${i}`]).mean()
})
Describe alternatives you've considered
The alternative option is to just get the actual Array object and use the Array.map() instead.
df[column].values.map((val, i) => {
if (i < 5) return 'N/A'
return df[column].iloc([`${i - 5}:${i}`]).mean()
})