В приведенном ниже коде каждый x имеет 9 значений y. Я хочу new_gamesplyed = [x, y1, y2, y3, y4, y5, y6, y7, y8, y9]. Но в списке «разница» все 292 значения сохраняются одновременно.
new_gamesplayed = []
difference = []
col_count = df_gamesplayed.shape[1]-1 = 9
l = len(df_gamesplayed) = 292
for x in range(len(df_gamesplayed)):
for y in range (1, col_count):
diff = abs(df_gamesplayed.iloc[x, y] - df_gamesplayed.iloc[x, y + 1])
difference.append(diff)
new_gamesplayed.append([df_gamesplayed.iloc[x, 0], difference])