# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import pandas as pd
import numpy as np


df = df= pd.read_csv("D:\STUDY\MBA\MBA 753\RapidMiner\GROCERY.csv")
print(len(df))
df.head()

# +
df.dropna(how='any', inplace=True)
# print(len(df))
# df.head()
count_False = 0
count_NaN = 0
for i in range(0,len(df)):
#     print(i)
    if (pd.isna(df.iloc[i,7])==False):
#         print(df.iloc[i,:])
        count_False = count_False + 1
    if (pd.isna(df.iloc[i,7])==True):
#         print(df.iloc[i,:])
        count_NaN = count_NaN + 1
    
print(count_NaN)
print(count_False)
# -

df.head()

# +
### CHANGING REVENUE COLUMN TO FLOAT
df['Revenue']  = df['Revenue'].str.replace('$', " ")
df['Revenue']  = df['Revenue'].str.replace(',', "")
df['Revenue'] = df['Revenue'].astype('float64')


count_False = 0
count_NaN = 0
for i in range(0,len(df)):
#     print(i)
    if (pd.isna(df.iloc[i,7])==False):
#         print(df.iloc[i,:])
        count_False = count_False + 1
    if (pd.isna(df.iloc[i,7])==True):
        print(df.iloc[i,:])
        count_NaN = count_NaN + 1
    
print(count_NaN)
print(count_False)
print(df.dtypes)
# -

df['Revenue'].max()

df['Gender'] = df['Gender'].map({'M': 'Male','F': 'Female','Male': 'Male','Female': 'Female' })
codes = {'Foods': 'Food', 'Drinks': 'Drink', 'None Consumable' : 'Non-Consumable',
         'Food': 'Food', 'Drink': 'Drink', 'Non-Consumable' : 'Non-Consumable'}
df['Product Category'] = df['Product Category'].map(codes)
# df1 = df.rename({'Product Category':'Product_Category'}, axis=1)
# df1.head()
print(df['Product Category'].unique())
print(df['Gender'].unique())
df.head()

df.plot(kind='box')

plt.figure()
df.boxplot(['Revenue'])

Rev_list = list(df['Revenue'])
Rev_list.sort(reverse = True)
print(Rev_list)

# +
import matplotlib.pyplot as plt
from pylab import rcParams
import seaborn as sb

# %matplotlib inline
rcParams['figure.figsize']=5,4
sb.set_style('whitegrid')
# -

sb.boxplot(x='Units Sold',y='Revenue', data=df,palette='hls')

df_rev=df['Revenue']
df_wo_outliers= (df_rev<48)
df=df[df_wo_outliers]
len(df[df_wo_outliers])

df.plot(kind='box')

print(df.describe())

plt.figure()
df.boxplot(['Units Sold'])

plt.figure()
df.boxplot(['Revenue'])

StarcoderdataJupyterScriptsDedupFiltered