Python 数据清洗、归一化和标准化处理代码示例
导入必要的库
import pandas as pd from sklearn.preprocessing import MinMaxScaler, StandardScaler
读取数据
data = pd.read_csv('data.csv')
清洗数据,例如删除重复值、缺失值等
归一化处理
scaler = MinMaxScaler() data[['col1', 'col2']] = scaler.fit_transform(data[['col1', 'col2']])
标准化处理
scaler = StandardScaler() data[['col3', 'col4']] = scaler.fit_transform(data[['col3', 'col4']])
保存处理后的数据
data.to_csv('processed_data.csv', index=False)
原文地址: https://www.cveoy.top/t/topic/oYEe 著作权归作者所有。请勿转载和采集!