weekday_cols = []
saturday_cols = []
sunday_cols = []
for column in orig_clustered_pk.columns:
weekday_cols.append(weekday_data[column].groupby(weekday_data.index.hour).mean())
saturday_cols.append(saturday_data[column].groupby(saturday_data.index.hour).mean())
sunday_cols.append(sunday_data[column].groupby(sunday_data.index.hour).mean())
weekday_averages = pd.concat(weekday_cols, axis=1)
saturday_averages = pd.concat(saturday_cols, axis=1)
sunday_averages = pd.concat(sunday_cols, axis=1)
I am trying to execute the code above and while it (probably) works as intended, it takes at least tens of minutes of time and uses massive amounts of memory. Is there a way to do the same in more efficient way?
I could maybe split it into 3 for loops for reduced memory usage, but it would still require too much time. My original data is approximately 8000×6000.