Difference makes the DIFFERENCE
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_excel('/content/ayaBook3.xlsx', sheet_name='book3_feb_21')
df['Date_Diff'] = df['Open_as_on'] - df['Post_Date']
# df.drop('DateDiff', inplace=True, axis=1)
df.Date_Diff
# df['Date_Diff'] = pd.to_numeric(df['Date_Diff'])
# df['tdColumn'] = df['tdColumn'].dt.days.astype('int16')
df['Date_Diff'] = df['Date_Diff'].dt.days.astype('int16')
df.info()
def aging(d_days):
if d_days < 30:
return "30 days"
elif d_days < 60:
return "60 days"
elif d_days < 90:
return "90 days"
elif d_days < 120:
return "120 days"
elif d_days < 150:
return "150 days"
elif d_days < 180:
return "180 days"
elif d_days < 360:
return "360 days"
else:
return "more than year"
df['aging'] = df['Date_Diff'].apply(aging)
df.to_excel("aging.xlsx", sheet_name="aging")