DM-exp-1/Interpolation.py
fly6516 3f2ae8adf5 feat(preprocessing): 添加数据预处理示例脚本
- 添加多个数据预处理示例脚本,包括离散化、去重、缺失值处理、插值、标准化等
- 新增 CheckNULL、Interpolation、Merge 等实用工具脚本
- 提供了不同的标准化方法示例,如标准差标准化、离差标准化、小数定标标准化
2025-03-30 02:55:48 +08:00

12 lines
573 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from scipy.interpolate import lagrange
import pandas as pd
import numpy as np
inputfile = '5Preprocessing/teleco_camp_orig.csv' #销量数据路径
camp = pd.read_csv(inputfile) #读入数据
for i in range(2,4):
la=lagrange(camp.iloc[:,i].dropna().index,camp.iloc[:,i].dropna().values)
list_d=list(set(np.arange(0,20)).difference(set(camp.iloc[:,i].dropna().index)))
camp.iloc[list_d,i]=la(list_d)
print("%d 列缺失值的个数为:%d"%(i,camp.iloc[:,i].isnull().sum()))
print("lagrange 插值后False 为缺失值所在位置)\n",camp.notnull())