import pandas as pd
import glob

folder_path = 'results' 

sizes = ['500', '1000', '2000', '5000', '10000']


for size in sizes:
    files = glob.glob(f'{folder_path}/timedata_{size}_epochs_*.csv')

    data = [pd.read_csv(f)['Время (сек)'] for f in files]

    datatomean = pd.concat(data, axis=1)
    datamean = datatomean.mean(axis=1)

    df = pd.read_csv(files[0])
    df['Время (сек)'] = datamean

    df.to_csv(f'results/aaverage_timedata_{size}.csv', index=False)
