<jupyter_start><jupyter_text>The Sparks Foundation - Internship  DOMAIN - Data Science and Bussines Analytics**TASK**+ Exploratory Data Analysis - Retail Business+ Performing "Exploratory Data Analysis" on dataset 'SampleSuperstore'**DATASET**+ The data which I have used in here for my EDA can be found here **GOAL**+ Will try to find out the weak areas where one can work to make more profit. + To derieve all the business problems one can derive from exploring the data. ANALYST - <NAME>   Exploratory Data Analysis - Retail Business<jupyter_code># importing necessary libraries

import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
# to ignore the depreciation warning if any, we import warnings package

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning) 
# importing dataset from the local file

retail_b = pd.read_csv('SampleSuperstore.csv')
# exploring the top 5 rows of data

retail_b.head()
# checking the dimensions of the dataframe

retail_b.shape
# checking the names of the columns in the retail_b dataframe

retail_b.columns
# extracting the info of each column (checking for the data_type and null values if any)

retail_b.info()
# to see the basic stats data of our imported dataframe

retail_b.describe()
# seeing if there is any null data or not

print(retail_b.count())

print('-----------------OR-----------------')

print(retail_b.isnull().sum())<jupyter_output>Ship Mode       9994
Segment         9994
Country         9994
City            9994
State           9994
Postal Code     9994
Region          9994
Category        9994
Sub-Category    9994
Sales           9994
Quantity        9994
Discount        9994
Profit          9994
dtype: int64
-----------------OR-----------------
Ship Mode       0
Segment         0
Country         0
City            0
State           0
Postal Code     0
Region          0
Category        0
Sub-Category    0
Sales           0
Quantity        0
Discount        0
Profit          0
dtype: int64<jupyter_text>**So we dont have any null values and all the data is properly arranged in the dataset and nothing is missing as we have full 9994 entries in each of the column.**<jupyter_code># now checking for any unique values present in the dataset

retail_b.nunique()<jupyter_output><empty_output><jupyter_text>**After checking for the unique values which might be present in the dataframe, we found out that:**+ In this dataset we are only dealoing with the country USA+ Postal Code will carry no meaning during our data analysis as we already have state and city mentioned.+ So we will be dropping those columns as it wont be needed during our data analysis<jupyter_code># dropping the columns "Country" and "Postal Code"

retail_b.drop(columns=['Country', 'Postal Code'], inplace=True)
retail_b.head()
# checking for any duplicity in the dataset

retail_dupli = retail_b.duplicated()
retail_dupli.sum()
retail_b.drop_duplicates()<jupyter_output><empty_output><jupyter_text>**Here when checking for duplicity, if there are any duplicate values it will return "True" or 1 in in the integer format, so therefore when we apply the sum method on the retail_dupli we get 50 means there are a total of 50 duplicate values. But after carefully seeing these are not exactly the kind of duplicate values which need to be removed. As its just that in some columns are having same values but not all.**<jupyter_code>#create the correlation matrix heat map

retail_corr = retail_b.corr()
plt.figure(figsize=(10,5))
sns.heatmap(retail_corr, xticklabels = retail_corr.columns, yticklabels = retail_corr.columns, linewidths=.1, \
            cmap="rocket", annot=True)
plt.yticks(rotation=0);
retail_by_ship_mode = retail_b.groupby('Ship Mode').agg('sum')
retail_by_ship_mode
plt.bar(retail_by_ship_mode.index,retail_by_ship_mode['Profit'])
plt.show()
profit_per_quantity_bought = retail_by_ship_mode['Profit'] / retail_by_ship_mode['Quantity']
plt.bar(retail_by_ship_mode.index,profit_per_quantity_bought )
plt.show()<jupyter_output><empty_output><jupyter_text>**So what we see is that the maximum profit is generated in the Standard Class Delievery Mode, but the maximum profit per quantity bought by customers is from First Class. So we should be paying more attention to the Standard Delievery Class along with First Class because if the customers are happy with the Standard Deleivery, it will automatically increase our sales and profit while also help beating other competitors in the market.**<jupyter_code># plotting the graph by "Segment" column to know the max profit

retail_by_segment = retail_b.groupby('Segment').agg('sum')
plt.bar(retail_by_segment.index, retail_by_segment['Profit'])
plt.show()
# plotting the graph by "Region" column to know the max profit

retail_by_region = retail_b.groupby('Region').agg('sum')
plt.bar(retail_by_region.index, retail_by_region['Profit'])
plt.show()
# plotting the graph by "Segment" column to know the average profit

retail_by_state = retail_b.groupby(["State"])["Profit"].mean().sort_values().index
sns.catplot(y="State",x="Profit",data=retail_b,kind='bar',ci=None,height=15,order=order)
plt.show()
# plotting the graph by "Category" column to know the max profit
sns.catplot(x="Category",y="Profit",data=retail_b,kind="bar",ci=None)
plt.show()
retail_by_sub_cat = retail_b.groupby('Sub-Category').agg(sum)
retail_by_sub_cat
plt.figure(figsize=(17,6))
plt.bar(retail_by_sub_cat.index,retail_by_sub_cat["Profit"])
plt.show()
#for different regions
sns.catplot(x="Category",y="Profit",data=retail_b,kind='bar',ci=None,col="Region")
plt.subplots(figsize=(8,12))
order=retail_b.groupby(['State'])["State"].count().sort_values().index
sns.countplot(y='State',data=retail_b,order=order)
plt.show()
# pairing plots
retail_pair = sns.pairplot(retail_b)
retail_pair<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0960326919802486, 'fraction_numerical': 0.015664907202451898, 'mean_word_length': 4.63183125599233, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '364049', 'license': 'MIT', 'n_tokens_mistral': 1854, 'n_tokens_neox': 1765, 'n_words': 624, 'path': 'Retail Business Analysis/Exploratory Data Analysis - Retail Business.ipynb', 'repo_name': 'Gaurav1921/Data-Science-Projects', 'size': '5879'}