0% found this document useful (0 votes)
8 views3 pages

SuperStore Sales and Profit Analysis

Uploaded by

tapasya2097
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

SuperStore Sales and Profit Analysis

Uploaded by

tapasya2097
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SuperStore Sales Analysis

import pandas as pd

import [Link] as px

import plotly.graph_objects as go

import [Link] as pio

[Link] = "plotly_white"

data = pd.read_csv("[Link]", encoding='latin-1')

print([Link]())

print([Link]())

data['Order Date'] = pd.to_datetime(data['Order Date'])

data['Ship Date'] = pd.to_datetime(data['Ship Date'])

data['Order Month'] = data['Order Date'].[Link]

data['Order Year'] = data['Order Date'].[Link]

data['Order Day of Week'] = data['Order Date'].[Link]

sales_by_month = [Link]('Order Month')['Sales'].sum().reset_index()

fig = [Link](sales_by_month,

x='Order Month',

y='Sales',

title='Monthly Sales Analysis')

[Link]()

sales_by_category = [Link]('Category')['Sales'].sum().reset_index()

fig = [Link](sales_by_category,

values='Sales',

names='Category',

hole=0.5,

color_discrete_sequence=[Link])
fig.update_traces(textposition='inside', textinfo='percent+label')

fig.update_layout(title_text='Sales Analysis by Category', title_font=dict(size=24))

[Link]()

sales_by_subcategory = [Link]('Sub-Category')['Sales'].sum().reset_index()

fig = [Link](sales_by_subcategory,

x='Sub-Category',

y='Sales',

title='Sales Analysis by Sub-Category')

[Link]()

profit_by_month = [Link]('Order Month')['Profit'].sum().reset_index()

fig = [Link](profit_by_month,

x='Order Month',

y='Profit',

title='Monthly Profit Analysis')

[Link]()

profit_by_category = [Link]('Category')['Profit'].sum().reset_index()

fig = [Link](profit_by_category,

values='Profit',

names='Category',

hole=0.5,

color_discrete_sequence=[Link])

fig.update_traces(textposition='inside', textinfo='percent+label')

fig.update_layout(title_text='Profit Analysis by Category', title_font=dict(size=24))

[Link]()

profit_by_subcategory = [Link]('Sub-Category')['Profit'].sum().reset_index()

fig = [Link](profit_by_subcategory, x='Sub-Category',


y='Profit',

title='Profit Analysis by Sub-Category')

[Link]()

sales_profit_by_segment = [Link]('Segment').agg({'Sales': 'sum', 'Profit':


'sum'}).reset_index()

color_palette = [Link]

fig = [Link]()

fig.add_trace([Link](x=sales_profit_by_segment['Segment'],

y=sales_profit_by_segment['Sales'],

name='Sales',

marker_color=color_palette[0]))

fig.add_trace([Link](x=sales_profit_by_segment['Segment'],

y=sales_profit_by_segment['Profit'],

name='Profit',

marker_color=color_palette[1]))

fig.update_layout(title='Sales and Profit Analysis by Customer Segment',

xaxis_title='Customer Segment', yaxis_title='Amount')

[Link]()

sales_profit_by_segment = [Link]('Segment').agg({'Sales': 'sum', 'Profit':


'sum'}).reset_index()

sales_profit_by_segment['Sales_to_Profit_Ratio'] = sales_profit_by_segment['Sales'] /
sales_profit_by_segment['Profit']

print(sales_profit_by_segment[['Segment', 'Sales_to_Profit_Ratio']])

You might also like