numpy 转成成pandas & pandas追加列

  1. 将numpy数据转换成pandas
  2. pandas追加一列
def fea2pd(X_train,y_train):
	# 训练数据转换成pandas结构
    columns = ["fea_"+str(i) for i in range(X_train.shape[1])]
    df_train = pd.DataFrame(X_train, columns)
    # pandas结构追加一列,(追加一列标签)
    df_train['targets'] = y_train

你可能感兴趣的:(python语法,python,pandas)