Is there a more succinct / pythonic / pandas-native way of writing the following?
all_pos = ['NN', 'VB', 'ADJ']
for col in all_pos:
df_out['delta_'+col] = df_out[col] - mean_df[col]
df_out and mean_df contain the same column names and indices, and I want to create new columns in df_out containing the difference between them.
So df_out could contain
Index NN VB ADJ
239 9 4 3
250 2 2 1
And df_mean could contain
Index NN VB ADJ
239 3 1 8
250 7 4 3
I would want df_out to look like
Index NN VB ADJ delta_NN delta_VB delta_ADJ
239 9 4 3 6 3 -5
250 2 2 1 -5 -2 -2