Python 数据清洗--处理Nan

参考:http://blog.sina.com.cn/s/blog_13050351e0102xfis.html
https://www.sogou.com/link?url=DOb0bgH2eKh1ibpaMGjuy-bS_O7xQYLPIOogrOFmc02ueKW9M67CaVLpMY1k7wxTCB1NmnNSzM-t5pUc3zy0dg..
https://www.sogou.com/link?url=DOb0bgH2eKh1ibpaMGjuy6YnbQPc3cuKWH5w_8iuvJBomuBEhdSpHkUUZED5fr2OXwl-dB-nkEs_c1NbUyGLxQ..
https://jingyan.baidu.com/article/ca00d56c1b3647e99eebcfbd.html

import numpy as np
import pandas as pd
from pandas import Series,DataFrame
from numpy import nan as NaN

import tensorflow as tf
import matplotlib.pyplot as plt

import scipy.io as sio
import os

from sklearn import preprocessing

读取mat数据
load_path="08_1.mat"
load_data = sio.loadmat(load_path)
a = load_data['D']
print(a)

data = DataFrame(a)
print(data)

data.fillna(0)
print(data.fillna(0))

b=data.fillna(0).values
print(b)

数据归一化
a2 = preprocessing.scale(b)
print('数据归一化:')
print(a2)

数据清洗方法2 删除NAN所在的列

load_path2="08_1.mat"
load_data2 = sio.loadmat(load_path2)
a2 = load_data2['D']

print(a2)

data2 = DataFrame(a2)
data2.dropna(axis=0, how='any')

print(data2.dropna(axis=0, how='any'))`

处理前:

处理后:

posted @ 2019-04-03 16:22  谁动了我的奶盖  阅读(2778)  评论(0编辑  收藏  举报