'How to use a created date_range as column headers instead of the dates in the data in pandas/python

I have a line of balance worksheet for supplier acknowledged ETA's and I have a separate line of balance worksheet for customer request dates. I have created both line of balances from a larger data file where I have created pivots showing material as index, year and week number as two separate columns, and balance as values (see below):

SupplierX=df[df.NAME.str.contains('SupplierX')]
SupplierCRD = SupplierX.pivot_table(
    index = ['MATERIAL'], 
    columns = ['CRD Year', 'CRD WN'], 
    values = ['BALANCE'], 
    aggfunc='sum', 
    fill_value = 0, 
    margins=True,
    margins_name = 'Total')

A separate line of balance is created exactly the same as above except the only difference is I want supplier acknowledgement dates instead of customer request dates. Then I need to subtract the acknowledgment balances from the CRD balances by week to see how many materials and which we will be short etc..I can complete this by using the df.subtract function only when I set the acknowledgement line of balance pivot columns to the CRD columns.

My problem: When the supplier has acknowledgment dates in weeks that there are no customer request dates. My thinking is I can solve this by creating a date range and using this created date range as columns and then feeding the data into that created date range. Is this possible?

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source