Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Salary.date = pd.to_datetime(Salary.date, format="%d-%m-%Y")
- check_Salary_date = Salary[Salary['date'].dt.day <= 5].groupby('date').sum()
- check_Salary_date.index = check_Salary_date.index.strftime('%d-%b-%y')
- check_Salary_date.index.name = 'Date'
- if not check_Salary_date.empty:
- print("Is salary credited before 5th:", True)
- print("List of salary credited before 5th : n", check_Salary_date)
- else:
- print("Is salary credited before 5th:", False)
- sum_Salary = Salary.groupby('date').sum()
- sum_Salary = Salary.groupby(pd.Grouper(key='date', freq='1M')).sum()
- sum_Salary_3months = Salary.groupby(pd.Grouper(key='date', freq='1M')).mean().dropna(subset=['Salary']).tail(3)
- avg_Salary_3months = sum_Salary_3months['Salary'].mean()
- sum_Salary.index = sum_Salary.index.strftime('%b-%y')
- sum_Salary.index.name = 'Date'
- total_Salary = len(sum_Salary.axes[0])
- print("nSalary received per month n", sum_Salary)
- print("--------------")
- print("Avg Salary of last 3 months :", avg_Salary_3months)
- Is salary credited before 5th: True
- List of date where salary received before 5th :
- Balance before Salary Salary
- Date
- 03-Aug-18 176.48 14783.0
- 04-Sep-18 48.48 16249.0
- 05-Oct-18 241.48 14448.0
- Salary received per month
- Balance before Salary Salary
- Date
- Jun-18 27.20 15300.0
- Jul-18 88.20 15300.0
- Aug-18 176.48 14783.0
- Sep-18 48.48 16249.0
- Oct-18 241.48 14448.0
- Nov-18 49.48 15663.0
- --------------
- Avg Salary of last 3 months : 15453.333333333334
- --------------
- [{"Is salary credited before 5th": "yes"},
- {
- "List of salary credited before 5th": {
- "Balance before Salary": {
- "03-Aug-18":176.48,
- "04-Sep-18":48.48,
- "05-Oct-18":241.48
- },
- "Salary": {
- "03-Aug-18":14783.0,
- "04-Sep-18":16249.0,
- "05-Oct-18":14448.0
- }
- }
- },
- {
- "Salary received per month": {
- "Balance before Salary": {
- "Jun-18":27.2,
- "Jul-18":88.2,
- "Aug-18":176.48,
- "Sep-18":48.48,
- "Oct-18":241.48,
- "Nov-18":49.48
- },
- "Salary": {
- "Jun-18":15300.0,
- "Jul-18":15300.0,
- "Aug-18":14783.0,
- "Sep-18":16249.0,
- "Oct-18":14448.0,
- "Nov-18":15663.0}
- }
- },
- {"Avg Salary of last 3 months" : 15453.333333333334}
- ]
Add Comment
Please, Sign In to add comment