Error:
"DataFrame is highly fragmented. This is usually the result of calling
frame.insertmany times, which has poor performance. Consider joining all columns at once using pd.concat(axis=1) instead. To get a de-fragmented frame, use `newframe = frame.copy()"
Code:
df_DIFFs = pd.DataFrame()
for a, b in itertools.permutations(df.columns,2):
df_DIFFs[f'{a}-{b}'] = df[a] - df[b]
df_DIFFs
I can't imagine how to use pd.concat or any other more efficient solution in this situation. Thanks.
source https://stackoverflow.com/questions/71018594/create-new-dataframe-by-substracting-every-column-with-each-other-solving-poor
Comments
Post a Comment