Created
August 19, 2018 22:45
-
-
Save ericness/64973b87b77f88d948607412dc59f44a to your computer and use it in GitHub Desktop.
Builds a MultiIndex of customer and date combinations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unique_customers = daily_orders.index.unique(level='customer') | |
date_range = pd.DatetimeIndex( | |
start=datetime(2018, 1, 1), | |
end=datetime(2018, 1, 10), | |
freq='D' | |
) | |
customer_date_index = ( | |
pd.MultiIndex | |
.from_product( | |
iterables=[unique_customers, date_range], | |
names=['customer', 'order_date'] | |
) | |
) | |
print(customer_date_index.values[:5]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment