Skip to content
Advertisement

interpolation of missing values not NA

I want to interpolate (linear interpolation) data. but not indicated NA.

Here is my data.

timestamp id strength
1383260400000 10 0.007802251505435157
1383260400000 11 0.0050101566841440105
1383260400000 47 0.09910993935546883
1383260400000 48 0.16302926693340128

and expected data is :

timestamp id strength
1383260400000 10 0.007802251505435157
1383260400000 11 0.0050101566841440105
1383260400000 12 interpolated strength
1383260400000 13 interpolated strength
1383260400000 14 interpolated strength
1383260400000 15 interpolated strength
1383260400000 16 interpolated strength
1383260400000 17 interpolated strength
1383260400000 interpolated strength
1383260400000 47 0.09910993935546883
1383260400000 48 0.16302926693340128

and there are data with another timestamp.

timestamp id strength
1383261000000 73 0.00034018953748529387
1383261000000 80 0.015745603609017354
1383261000000 81 0.01332206498346922
1383261000000 101 0.003292329017912283
1383261000000 102 0.0028735259562922954
1383261000000 103 0.0033962211735905955

and the last id is 2025 and timestamp is 13833462000000

Advertisement

Answer

First convert values of id to index, so possible use lambda function in GroupBy.apply with Series.reindex and Series.interpolate:

JavaScript

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement