问题描述,想要形如[1,2,3,4]的列表变成[1,2,3,4,1,2,3,4,1,2,3,4]的形式
feature = list(range(1, 5, 1))#一共4个特征
features = 3*feature
features
out:[1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
问题描述:想要形如[1,2,3,4]的列表变成[1,1,1,2,2,2,3,3,3,4,4,4]的形式
month = [1,2,3,4,5]
year = [val for val in month for i in range(3)]
year
out:[1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]