fillmthd()

阅读(1385) 标签: 填充, 缺失值, 向量, 矩阵,

描述:

按照指定方法填充缺失值。

语法:

A.fillmthd(m)

备注:

按照指定的方法m填充AA为向量或矩阵。

填充方法有四种:

1或“previous”:上⼀个⾮缺失值;

2或“next”:下⼀个⾮缺失值;

3或“nearest”:距离最近的⾮缺失值;

4或“linear”:相邻⾮缺失值的线性插值,仅限数值,数据输⼊时需要是double类型(带⼩数点)。

参数:

A

序列。

m

填充方法。

返回值:

序列

示例:

 

A

 

1

=[1,,2,,2,,,5,,7,,8]

2

=A1.fillmthd("previous")

3

=[[1,2,,,5,,7,8],[2,3,4,,,,5,]]

 

4

=A3.fillmthd(1)

返回[[1,2,2,2,5,5,7,8],[2,3,4,4,4,4,5,5]]

5

=["one","two"," ","one"," "," "," ","two"," "]

 

6

=A5.fillmthd("next")

7

=[1.0,3.0,,,5.0,]

 

8

=A7.fillmthd("linear")