摘要: 1. 保存list import numpy as np a = [1,2,3,4,5] np.save("number.npy", a) k = np.load("number.npy") 2. 保存map import json data = {} data["a"] = 1 data["b"] 阅读全文
posted @ 2020-12-06 18:54 qiezi_online 阅读(4279) 评论(0) 推荐(1) 编辑
摘要: # 3.离散值进行LabelEncoder #处理数据的三个步骤,去重,处理缺失值,离散值LabelEncoder from sklearn import preprocessingfrom sklearn.externals import joblib categorical_ix = ["1", 阅读全文
posted @ 2020-12-06 18:52 qiezi_online 阅读(1102) 评论(0) 推荐(0) 编辑
摘要: # 2.1处理缺失值,连续值用均值填充 continuous_fillna_number = [] for i in train_null_ix: if(i in continuous_ix): mean_v = df_train[i].mean() continuous_fillna_number 阅读全文
posted @ 2020-12-06 18:34 qiezi_online 阅读(168) 评论(0) 推荐(0) 编辑
摘要: s = df.isnull().any() #返回series形式,可以用enumerate打印s #true代表有空值 null_index = [] for i,j in enumerate(s): print(i,j,s.index[i]) if(j): null.index.append(s 阅读全文
posted @ 2020-12-06 16:53 qiezi_online 阅读(722) 评论(0) 推荐(0) 编辑
摘要: import pandas as pd df = pd.DataFrame(np.random.randn(3,4),columns=['a','b','c','d']) k = df.pop("b") df.insert(df.shape[1],"label",k) #将b列移到了最后一列去 df 阅读全文
posted @ 2020-12-06 16:17 qiezi_online 阅读(2995) 评论(0) 推荐(0) 编辑
摘要: import csvdef convert_txt_to_csv(out_file_path, input_file_path, txt_sep): #定义输出路径,输入文件路径,txt的分隔符 with open("./temp.csv", "w", newline = "") as csv_fi 阅读全文
posted @ 2020-12-06 15:51 qiezi_online 阅读(650) 评论(0) 推荐(0) 编辑
摘要: head -n 100 train.txt > 123.txt head -100 train.txt > 123.txt 阅读全文
posted @ 2020-12-06 15:14 qiezi_online 阅读(699) 评论(0) 推荐(0) 编辑