<jupyter_start><jupyter_text>TOTAL NUMER OF ORDERS FROM 16TH MARCH - 15TH APRIL<jupyter_code>print(df15mar_15apr_slc_col_dups)<jupyter_output>customer_id  freq
0     5c15fb165d8a4afc8c1dad7850104056    20
1     c0f42047fe384b199c7fb216da5f1c25    16
2     0b2e2cb5801144eca4a8c7c8cd1673a2    15
3     1d3bb8e528c949bb9bcb191abb0c1dd5    13
4     d61ebf98b24248779f85bd11f1da68fb    11
...                                ...   ...
2190  9a5acb8e30fb4bf98a953eb8e52fb468     2
2191  9a9ff7f0622e4be7a20b4ba843d76544     2
2192  9aaf21e83a1645b9b4963245f45ae353     2
2193  9ab72d6a52144165a2f3cd928e1ddb2e     2
2194  0011bf17a68041c587cf7b3c9e09285d     2

[2195 rows x 2 columns]<jupyter_text>CUSTOMERS WITH ORDERS > 1. FROM 16TH MARCH - 15TH APRIL<jupyter_code>#FINDING CUSTOMERS WHO ORDERED EXACTLY 1 TIMES
#CALCULATING FREQUENCY BY PIVOTING
cust_ordered_1_time = df15mar_15apr_slc_col.pivot_table(index=['customer_id'], aggfunc='size').sort_values(ascending= False)
#Converting from series to dataframe
cust_ordered_1_time = cust_ordered_1_time.to_frame()
#NAming third column
cust_ordered_1_time = cust_ordered_1_time.rename(columns = {0: "freq"})
#Setting the Index
cust_ordered_1_time = cust_ordered_1_time.loc[cust_ordered_1_time['freq'] == 1] 
cust_ordered_1_time.reset_index(inplace= True)

print(cust_ordered_1_time)<jupyter_output>customer_id  freq
0      53f296df031c4c41bd0901bbc70d75f5     1
1      5394495cd16d4c378a1b1f145cf379f6     1
2      4800c98ba2b945cda59463107f21e226     1
3      541e326b151646e085c40fdb36bf65ba     1
4      480d910f91194a23bc83979ed15435e8     1
...                                 ...   ...
12899  a56ae3900dfd4db19e9857920721efba     1
12900  a556ab40eac742368bcec95025c6fc7d     1
12901  a5568fbf953e41fb867a91ec447d93ec     1
12902  a5490f375cab4fb2bb029d39105ec1ce     1
12903  0001370ecc044bbdaf598d8c229fe42b     1

[12904 rows x 2 columns]<jupyter_text>CUSTOMERS WITH EXACTLY 1 ORDER FROM 16TH MARCH TO 15TH APRIL<jupyter_code>#AMONG FRQUENT CUSTOMERS FINDING WHICH CUSTOMERS ARE NOT ORDERING NOW FREQUENTLY

#GIVING INPUT FOR SELECTED DATE 
import copy
df2 = copy.deepcopy(df)


df2['created_on']= pd.to_datetime(df2['created_on'])
df2['created_on'].dt.tz_localize(None)
#TypeError: Cannot compare tz-naive and tz-aware datetime-like objects, HENCE SPLITTING DATE AND TIME
df2['Dates'] = pd.to_datetime(df2['created_on']).dt.date
df2 = df2[['customer_id','Dates']]

start_date_obj= datetime.datetime.strptime('2020-04-15', '%Y-%m-%d').date()
mask = (df2['Dates'] > start_date_obj)
df2 = df2.loc[mask]

#RESETTING INDEX
df2 = df2.sort_values(by=['Dates'])#FUNCTION TO FILTER DATA BY DATE
df2.reset_index(inplace= True)#RESET INDEX
df2 = df2[['customer_id','Dates']]#REMOVING OLD INDEX COLUMN

################################################################################################
      
listt=[]
for i in df15mar_15apr_slc_col_dups['customer_id']:
    if i not in df2.values:
       listt.append(i)       
print(len(listt))<jupyter_output>2055<jupyter_text>NUMBER OF CUSTOMERS WHO ARE NOT ORDERING AFTER 15TH APRIL TILL TODAY CUSTOMERS WITH > 1 ORDER FROM 16TH MARCH TO 15TH IS 859, AMONG THOSE 859 CUSTOMERS, 769 OF CUSTOMERS HAVE NOT PLACED ANY ORDER AFTER 15TH OF APRIL<jupyter_code>#CONSIDERING MORE THAN 2 ORDERS
rslt_df = df15mar_15apr_slc_col_dups.loc[df15mar_15apr_slc_col_dups['freq'] >= 1] 
 
listt2=[]
for i in rslt_df['customer_id']:
    if i not in df2.values:
       listt2.append(i)
       
print(rslt_df)
print(len(listt2))<jupyter_output>2055<jupyter_text>Total customers with > 2 orders from 16th march - 15th april is "252"<jupyter_code>Customers_not_ordering = pd.DataFrame(listt2) 
Customers_not_ordering
Customers_not_ordering = Customers_not_ordering.rename(columns = {0: "customer_id"})
Customers_not_ordering.to_excel(r'H:\intern_lovelocal\customers_not_ordering_new.xlsx', index = False)<jupyter_output><empty_output><jupyter_text>AMONG THOSE 252 CUSTOMERS NUMBER OF CUSTOMERS WITH MORE THAN 2 ORDERS IN PREV MONTH BUT DID NOT PLACED ANY ORDER AFTER 15TH APRIL CUSTOMERS WITH > 2 ORDER FROM 16TH MARCH TO 15TH IS 859, AMONG THOSE 859 CUSTOMERS, 769 OF CUSTOMERS HAVE NOT PLACED ANY ORDER AFTER 15TH OF APRIL  DID SEPARATELY FOR CUSTOMERS WITH  > 2 AND > 1 ORDERS, BECAUSE, CUSTOMERS WITH EXATLY 2 ORDERS FROM 16TH MARCH - 15TH APRIL  ARE = NEARLY  600 (BIG AMOUNT)  FROM TOTAL OF JUST 859 CUSTOMERS. HENCE CALCULATING FOR CUSTOMERS > 2 ORDERS FROM 16MAR- 15APRIL BUT NOT PLCAING ORDERS AFTER THAT BECOMES THE NECESSITY FOR THE PROPER RESULTS AND FURTHER WORK<jupyter_code>customer_not_ordering_latest = pd.merge(left=Customers_not_ordering, right=rslt_df, how='left', left_on='customer_id', right_on='customer_id')
customer_not_ordering_latest.head(10).style.background_gradient(cmap='Blues')
customer_not_ordering_latest
customer_not_ordering_latest.to_excel(r'H:\intern_lovelocal\customer_not_ordering_latest.xlsx', index = False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09414141414141414, 'fraction_numerical': 0.1301010101010101, 'mean_word_length': 5.347435897435897, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '122684', 'license': 'MIT', 'n_tokens_mistral': 2408, 'n_tokens_neox': 1995, 'n_words': 407, 'path': 'customer_not_ordering_analysis.ipynb', 'repo_name': 'vivek1240/Customers_not_ordering_analysis', 'size': '4950'}