Guest User

Untitled

a guest
Dec 18th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. Salary.date = pd.to_datetime(Salary.date, format="%d-%m-%Y")
  2. check_Salary_date = Salary[Salary['date'].dt.day <= 5].groupby('date').sum()
  3. check_Salary_date.index = check_Salary_date.index.strftime('%d-%b-%y')
  4. check_Salary_date.index.name = 'Date'
  5. if not check_Salary_date.empty:
  6. print("Is salary credited before 5th:", True)
  7. print("List of salary credited before 5th : n", check_Salary_date)
  8. else:
  9. print("Is salary credited before 5th:", False)
  10. sum_Salary = Salary.groupby('date').sum()
  11. sum_Salary = Salary.groupby(pd.Grouper(key='date', freq='1M')).sum()
  12. sum_Salary_3months = Salary.groupby(pd.Grouper(key='date', freq='1M')).mean().dropna(subset=['Salary']).tail(3)
  13. avg_Salary_3months = sum_Salary_3months['Salary'].mean()
  14. sum_Salary.index = sum_Salary.index.strftime('%b-%y')
  15. sum_Salary.index.name = 'Date'
  16. total_Salary = len(sum_Salary.axes[0])
  17. print("nSalary received per month n", sum_Salary)
  18. print("--------------")
  19. print("Avg Salary of last 3 months :", avg_Salary_3months)
  20.  
  21. Is salary credited before 5th: True
  22. List of date where salary received before 5th :
  23. Balance before Salary Salary
  24. Date
  25. 03-Aug-18 176.48 14783.0
  26. 04-Sep-18 48.48 16249.0
  27. 05-Oct-18 241.48 14448.0
  28.  
  29. Salary received per month
  30. Balance before Salary Salary
  31. Date
  32. Jun-18 27.20 15300.0
  33. Jul-18 88.20 15300.0
  34. Aug-18 176.48 14783.0
  35. Sep-18 48.48 16249.0
  36. Oct-18 241.48 14448.0
  37. Nov-18 49.48 15663.0
  38. --------------
  39. Avg Salary of last 3 months : 15453.333333333334
  40. --------------
  41.  
  42. [{"Is salary credited before 5th": "yes"},
  43.  
  44. {
  45. "List of salary credited before 5th": {
  46. "Balance before Salary": {
  47. "03-Aug-18":176.48,
  48. "04-Sep-18":48.48,
  49. "05-Oct-18":241.48
  50.  
  51. },
  52. "Salary": {
  53. "03-Aug-18":14783.0,
  54. "04-Sep-18":16249.0,
  55. "05-Oct-18":14448.0
  56.  
  57. }
  58. }
  59. },
  60. {
  61. "Salary received per month": {
  62. "Balance before Salary": {
  63. "Jun-18":27.2,
  64. "Jul-18":88.2,
  65. "Aug-18":176.48,
  66. "Sep-18":48.48,
  67. "Oct-18":241.48,
  68. "Nov-18":49.48
  69.  
  70. },
  71. "Salary": {
  72. "Jun-18":15300.0,
  73. "Jul-18":15300.0,
  74. "Aug-18":14783.0,
  75. "Sep-18":16249.0,
  76. "Oct-18":14448.0,
  77. "Nov-18":15663.0}
  78. }
  79. },
  80.  
  81. {"Avg Salary of last 3 months" : 15453.333333333334}
  82. ]
Add Comment
Please, Sign In to add comment