I would like to merge two Pandas dataframes together and control the names of the new column values.
I originally created the dataframes from CSV files. The original CS
You can rename all the columns of ad by setting its columns as follows.
ad.columns = ['org', 'name', 'presents_spend', 'trees_spend']
The suffixes
option in the merge function does this. The defaults are suffixes=('_x', '_y')
.
In general, renaming columns can be done with the rename method.
Another way is adding suffix to the columns of your dataframe before merging:
ad.columns = 'ad_' + ad.columns.values