时间序列中缺失值的插值
我有一个看起来像这样的日期集(显示数据的尾部) -
YearMonth Rose
172 1994-05 44.0
173 1994-06 45.0
174 1994-07 NaN
175 1994-08 NaN
176 1994-09 46.0
177 1994-10 51.0
178 1994-11 63.0
正如您所看到的,有两个缺失值。为了纠正它,我使用以下代码 -
df.interpolate(method='spline',order=1, limit=2)['Rose']
但它不起作用。它仍然显示存在空值。我做错了什么?如何修复它?
此外,尚未设置索引,“年月”和“玫瑰”的数据类型分别为对象和浮点数。
I have a dateset that looks like this (showing the tail end of data)-
YearMonth Rose
172 1994-05 44.0
173 1994-06 45.0
174 1994-07 NaN
175 1994-08 NaN
176 1994-09 46.0
177 1994-10 51.0
178 1994-11 63.0
As you can see, there are two missing values. To correct it i am using the following code-
df.interpolate(method='spline',order=1, limit=2)['Rose']
But its not working. It still shows that there are null values. What am i doing wrong? How to fix it?
Also, no index has been set and datatypes are object and float for 'Year Month' and Rose respectively.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论