Currently when I have to add a constant column to an existing data frame, I do the following. To me it seems not all that elegant (the part where I multiply by length of dataframe). Wondering if there are better ways of doing this.
import pandas as pd
testdf = pd.DataFrame({'categories': ['bats', 'balls', 'paddles'],
'skus': [50, 5000, 32],
'sales': [500, 700, 90]})
testdf['avg_sales_per_sku'] = [testdf.sales.sum() / testdf.skus.sum()] * len(testdf)