在上采样后将numpy.ndarry转换为DataFrame维护索引

时间:2018-02-13 12:48:54

标签: multisampling

X_train_1, X_test_1, y_train_1, y_test = train_test_split(x, y,
                                              test_size = .3)

X_train_sam, y_train_sam = ADASYN(random_state=42).fit_sample(X_train_1, y_train_1)

type(X_train_1)
pandas.core.frame.DataFrame

X_train_1.shape
(1668, 353)

type(X_train_sam)
numpy.ndarray

X_train_sam.shape
(2698, 353)

如何将 X_train_sam 转换回数据框,以便与 X_train_1 相同,并在为新数据添加索引时维护索引?

1 个答案:

答案 0 :(得分:0)

这样的事情:

if(ws.Cell(i, j).HasFormula) 
       VAL = ws.Cell(i, j).ValueCached
else
       VAL = ws.Cell(i, j).Value.ToString()