'Pandas: Strange result when doing polynomial interpolation on full and a random part of a column
Suppose we want to impute NaN values via a polynomial approach.
Apply interpolate() on the full column or on the some random sample of it, with different sample size and seed,
df['col'].sample(n=90000, random_state=3).interpolate(method='quadratic')
or
df['col'].interpolate(method='quadratic')
returns the following error:
ValueError: Expect x to be a 1-D sorted array_like
However, another sample of the full column returns the interploated values; for example:
df['col'].sample(n=80000, random_state=3).interpolate(method='quadratic')
key_0
2010-01-25 03:57:12+00:00 0.049510
2009-07-11 16:17:49+00:00 0.049510
2014-02-08 02:02:53+00:00 718.357600
2018-02-07 15:04:19+00:00 8329.784418
2012-04-26 16:31:41+00:00 5.085041
...
2021-04-02 21:17:19+00:00 59195.319864
2010-06-26 02:36:05+00:00 0.049510
2011-07-12 12:45:45+00:00 14.068166
2011-10-05 09:17:26+00:00 4.917494
2020-02-21 15:05:16+00:00 9715.984813
Name: col, Length: 80000, dtype: float64
Does anyone know what prevents interpolation to apply on the full Series?
EDIT:
Here is the data needed: https://www.dropbox.com/s/sey9lzalwd3ljtc/full_data.parquet
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
