Created
October 19, 2020 08:49
-
-
Save manmohan24nov/c3ad9ec086afa4c2180b424da8e7405a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| In [2]: weekly_sales_df = sales_data[['Store', | |
| ...: 'Date', | |
| ...: 'Weekly_Sales']].groupby(['Store', | |
| ...: 'Date']).agg({'Weekly_Sales':'mean'}) | |
| In [3]: weekly_sales_df.reset_index(inplace=True) | |
| In [4]: weekly_sales_df['Percent_weekly_sales'] = weekly_sales_df.groupby(['Date'])['Weekly_Sales'].rank(pct=True, | |
| ...: ascending=False) | |
| In [6]: weekly_sales_df[weekly_sales_df['Date']=='25/11/2011'].sort_values(by='Percent_weekly_sales', ascending=False) | |
| Out[6]: | |
| Store Date Weekly_Sales Percent_weekly_sales | |
| 546 4 25/11/2011 40604.085541 1.000000 | |
| 1404 10 25/11/2011 39867.549189 0.977778 | |
| 2834 20 25/11/2011 39811.414384 0.955556 | |
| 1833 13 25/11/2011 38188.941467 0.933333 | |
| 1976 14 25/11/2011 37821.856479 0.911111 | |
| 260 2 25/11/2011 35810.990411 0.888889 | |
| 3835 27 25/11/2011 34306.859041 0.866667 | |
| 5551 39 25/11/2011 32941.301408 0.844444 | |
| 832 6 25/11/2011 30402.858784 0.822222 | |
| 3263 23 25/11/2011 28570.271250 0.800000 | |
| 117 1 25/11/2011 27853.707671 0.777778 | |
| 2691 19 25/11/2011 27425.649722 0.755556 | |
| 4407 31 25/11/2011 26862.495139 0.733333 | |
| 5837 41 25/11/2011 26482.129861 0.711111 | |
| 3978 28 25/11/2011 26434.770822 0.688889 | |
| 4979 35 25/11/2011 25877.946269 0.666667 | |
| 1547 11 25/11/2011 25328.129863 0.644444 | |
| 3406 24 25/11/2011 24126.516027 0.622222 | |
| 4550 32 25/11/2011 23395.398056 0.600000 | |
| 2548 18 25/11/2011 22875.647746 0.577778 | |
| 1690 12 25/11/2011 22741.720286 0.555556 | |
| 3120 22 25/11/2011 22258.804203 0.533333 | |
| 4836 34 25/11/2011 18688.830833 0.511111 | |
| 3692 26 25/11/2011 17810.000694 0.488889 | |
| 2977 21 25/11/2011 17670.484058 0.466667 | |
| 2405 17 25/11/2011 17510.004000 0.444444 | |
| 1118 8 25/11/2011 17396.674085 0.422222 | |
| 6409 45 25/11/2011 17215.778529 0.400000 | |
| 5694 40 25/11/2011 16849.478767 0.377778 | |
| 3549 25 25/11/2011 15945.877000 0.355556 | |
| 2119 15 25/11/2011 15020.818310 0.333333 | |
| 975 7 25/11/2011 13754.722754 0.311111 | |
| 4121 29 25/11/2011 13629.331194 0.288889 | |
| 6123 43 25/11/2011 13399.304400 0.266667 | |
| 1261 9 25/11/2011 12344.750000 0.244444 | |
| 5980 42 25/11/2011 11327.419020 0.222222 | |
| 5265 37 25/11/2011 10451.080800 0.200000 | |
| 2262 16 25/11/2011 10034.118310 0.177778 | |
| 4264 30 25/11/2011 8695.460192 0.155556 | |
| 403 3 25/11/2011 8568.079846 0.133333 | |
| 5408 38 25/11/2011 7874.314200 0.111111 | |
| 689 5 25/11/2011 7580.598060 0.088889 | |
| 5122 36 25/11/2011 7395.812222 0.066667 | |
| 6266 44 25/11/2011 6308.755306 0.044444 | |
| 4693 33 25/11/2011 5565.140652 0.022222 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment