複数行の複数列を複数行の1列、すなわち多層インデックスに変換
4277 ワード
group_data_dict = {}
for name, group in factor_data.groupby(color[color.columns[0]]):
iterable = [group.iloc[:, 0].tolist(), group.columns[1:].tolist()]
group_data = pd.DataFrame(group.iloc[:, 1:].values.reshape(-1),
index=pd.MultiIndex.from_product(iterable, names=['glass_id', 'measure_point']),
columns=['measure_value'])
group_data2 = group_data.reset_index()
cols = ['measure_value', 'glass_id', 'measure_point']
group_data3 = group_data2.loc[:, cols]