#coding:utf8
import pandas as pd
import numpy as np
from pandas import Series,DataFrame
# 如果有id列,则需先删除id列再进行对应操作,最后再补上
# 统计的时候不需要用到id列,删除的时候需要考虑
# delete row
def row_del(df, num_percent, label_len = 0):
#print list(df.count(axis=1))
col_num = len(list(list(df.values)[1])) - label_len # -1为考虑带标签
if col_num<0:
print 'Error'
#print int(col_num*num_percent)
return df.dropna(axis=0, how='any', thresh=int(col_num*num_percent))
# 如果有字符串类型,则报错
# data normalization -1 to 1
# label_col: 不需考虑的类标,可以为字符串或字符串列表
# 数值类型统一到float64
def data_normalization(df, label_col = []):
lab_len = len(label_col)
print label_col
if lab_len>0:
df_temp = df.drop(label_col, axis = 1)
df_lab