Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 熊猫插值后剩下的南_Python_Pandas - Fatal编程技术网

Python 熊猫插值后剩下的南

Python 熊猫插值后剩下的南,python,pandas,Python,Pandas,我有以下熊猫系列: 0 NaN 1 NaN 2 NaN 3 NaN 4 NaN 5 NaN 6 NaN 7 NaN 8 NaN 9 NaN 10 NaN 11 2.291958 12 NaN 13 NaN 14 NaN

我有以下熊猫系列:

0           NaN
1           NaN
2           NaN
3           NaN
4           NaN
5           NaN
6           NaN
7           NaN
8           NaN
9           NaN
10          NaN
11     2.291958
12          NaN
13          NaN
14          NaN
15          NaN
16          NaN
17          NaN
18          NaN
19          NaN
20          NaN
21          NaN
22          NaN
23          NaN
24          NaN
25          NaN
26     0.378826
27          NaN
28          NaN
29          NaN
         ...   
123         NaN
124         NaN
125         NaN
126         NaN
127    1.170094
128         NaN
129         NaN
130         NaN
131    0.008531
132         NaN
133         NaN
134         NaN
135         NaN
136         NaN
137         NaN
138         NaN
139         NaN
140         NaN
141         NaN
142         NaN
143         NaN
144         NaN
145         NaN
146         NaN
147         NaN
148         NaN
149         NaN
150         NaN
151         NaN
152         NaN
Length: 153, dtype: float64
我将其插入如下:

ts.interpolate(method='cubic', limit_direction='both', limit=75)
0           NaN
1           NaN
2           NaN
3           NaN
4           NaN
5           NaN
6           NaN
7           NaN
8           NaN
9           NaN
10          NaN
11     2.291958
12     1.733142
13     1.255447
14     0.854370
15     0.525409
16     0.264062
17     0.065826
18    -0.073801
19    -0.159321
20    -0.195237
21    -0.186051
22    -0.136265
23    -0.050382
24     0.067095
25     0.211666
26     0.378826
27     0.564074
28     0.762908
29     0.970824
         ...   
123    1.649933
124    1.579817
125    1.479152
126    1.343917
127    1.170094
128    0.953663
129    0.690605
130    0.376900
131    0.008531
132         NaN
133         NaN
134         NaN
135         NaN
136         NaN
137         NaN
138         NaN
139         NaN
140         NaN
141         NaN
142         NaN
143         NaN
144         NaN
145         NaN
146         NaN
147         NaN
148         NaN
149         NaN
150         NaN
151         NaN
152         NaN
Length: 153, dtype: float64
我本以为所有的NaN都会用这个来填充,但在输出中,NaN仍然存在,为什么会这样?我如何在
interpolate
命令中修复它?输出如下:

ts.interpolate(method='cubic', limit_direction='both', limit=75)
0           NaN
1           NaN
2           NaN
3           NaN
4           NaN
5           NaN
6           NaN
7           NaN
8           NaN
9           NaN
10          NaN
11     2.291958
12     1.733142
13     1.255447
14     0.854370
15     0.525409
16     0.264062
17     0.065826
18    -0.073801
19    -0.159321
20    -0.195237
21    -0.186051
22    -0.136265
23    -0.050382
24     0.067095
25     0.211666
26     0.378826
27     0.564074
28     0.762908
29     0.970824
         ...   
123    1.649933
124    1.579817
125    1.479152
126    1.343917
127    1.170094
128    0.953663
129    0.690605
130    0.376900
131    0.008531
132         NaN
133         NaN
134         NaN
135         NaN
136         NaN
137         NaN
138         NaN
139         NaN
140         NaN
141         NaN
142         NaN
143         NaN
144         NaN
145         NaN
146         NaN
147         NaN
148         NaN
149         NaN
150         NaN
151         NaN
152         NaN
Length: 153, dtype: float64

我不认为cubic可以在没有中间值的情况下对
fillna
执行此操作,如果您更改
线性
,它将执行此操作

s.interpolate('linear',limit_direction='both', limit=75)
Out[62]: 
0     2.291958
1     2.291958
2     2.291958
3     2.291958
4     2.291958
5     2.291958
6     2.291958
7     2.291958
8     2.291958
9     2.291958
10    2.291958
11    2.291958
12    2.164416
13    2.036874
14    1.909332
15    1.781789
16    1.654247
17    1.526705
18    1.399163
19    1.271621
20    1.144079
21    1.016537
22    0.888995
23    0.761452
24    0.633910
25    0.506368
26    0.378826
27    0.378826
28    0.378826
29    0.378826
Name: s, dtype: float64

那么你想要立方的方法吗?“Inter-”意思是“介于”(给定点之间)。你想要的是外推。@DYZ,我想使用'limit\u direction='tware``就可以了extrapolation@Wen-Ben,我不喜欢
cubic
linear
可以。toothanks@Wen Ben,你知道为什么
cubic
失败吗?这是因为没有实现该功能吗?@user308827您可以检查scipy三次曲线,具体取决于它如何获得样条线