Last active
May 2, 2020 09:06
-
-
Save anbento0490/62df7699aa7a21766be60ebddd694c30 to your computer and use it in GitHub Desktop.
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
#1. ROW NUMBER() --> .RANK(method='first') | |
# Ranks orders over time by Custoner ID | |
orders['Row Num'] = orders.groupby(['Customer ID'])['Order Date'].rank(method='first') | |
# Sorts values by Customer ID and Order Date in ascending order | |
orders.sort_values(by= ['Customer ID','Order Date'], inplace = True) | |
orders = orders.reset_index(drop = True) | |
orders.head(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment