File size: 4,329 Bytes
2ce3fcd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# -*- coding: utf-8 -*-
""".211
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1uZZV_SkJj2tua-CdVEbGu85Tl8vrTbWD
"""
import numpy as np
import pandas as pd
import os
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
data = pd.read_csv('/content/synthetic_ecommerce_data.csv')
print("Dataset Preview:")
print(data.head())
print("\nDescriptive Statistics:")
print(data.describe(include='all'))
print("\nMissing Values:")
print(data.isnull().sum())
data['Transaction_Date'] = pd.to_datetime(data['Transaction_Date'])
daily_revenue = data.groupby('Transaction_Date')['Revenue'].sum()
plt.figure(figsize=(10, 5))
plt.plot(daily_revenue, label='Daily Revenue')
plt.title('Revenue Over Time')
plt.xlabel('Date')
plt.ylabel('Revenue')
plt.legend()
plt.show()
top_products = data.groupby('Product_ID')['Revenue'].sum().sort_values(ascending=False).head(10)
plt.figure(figsize=(10, 5))
top_products.plot(kind='bar')
plt.title('Top 10 Products by Revenue')
plt.xlabel('Product Id')
plt.show()
category_revenue = data.groupby('Category')['Revenue'].sum()
plt.figure(figsize=(10, 5))
sns.scatterplot(x=data=['Ad_Spend'], y=data['Revenue'])
plt.title('Ad Spend vs Revenue')
plt.xlabel('Ad Spend')
plt.ylabel('Revenue')
plt.show()
plt.figure(figsize=(10, 5))
sns.histplot(data['Ad_CTR'], bins=20, kde=True)
plt.title('Distribution of Ad Click-Through Rate (CTR)')
plt.xlabel('CTR')
plt.ylabel('Frequency')
plt.show()
region_revenue = data.groupby('Region')['Revenue'].sum()
plt.figure(figsize=(10, 5))
region_revenue.plot(kind='bar')
plt.title('Revenue by Region')
plt.xlabel('Region')
plt.ylabel('Revenue')
plt.show()
data['Month'] = data['Transaction_Date'].dt.month
monthly_revenue = data.groupby('Month')['Revenue'].sum()
plt.figure(figsize=(10, 5))
monthly_revenue.plot(kind='bar')
plt.title('Monthly Reveneu Trend')
plt.xlabel('Month')
plt.ylabel('Revenue')
plt.show()
plt.figure(figsize=(10, 5))
sns.scatterplot(x=data['Discount_Applied'], y=data['Revenue'])
plt.title('Discount Applied vs Revenue')
plt.xlabel('Discount (%)')
plt.ylabel('Revenue')
plt.show()
plt.figure(figsize=(10, 5))
sns.scatterplot(x=data['Clicks'], y=data['Revenue'])
plt.title('Clicks vs Revenue')
plt.ylabel('Revenue')
plt.show()
plt.figure(figsize=(10, 5))
sns.histplot(data['Conversion_Rate'], bins=20, kde=True)
plt.title('Distribution of Conversion Rate')
plt.xlabel('Conversion Rate')
plt.ylabel('Frequency')
plt.show()
plt.figure(figsize=(10, 5))
sns.scatterplot(x=data['Conversion_Rate'], y=data['Revenue'])
plt.title('Conversion Rate vs Revenue')
plt.xlabel('Conversion Rate')
plt.ylabel('Revenue')
plt.show()
region_revenue = data.groupby('Region')['Revenue'].sum()
total_revenue = region_revenue.sum()
region_contribution = (region_revenue / total_revenue) * 100
plt.figure(figsize=(10, 5))
region_contribution.plot(kind='bar')
plt.title('Revenue Contribution by Reigion (%)')
plt.xlabel('Region')
plt.ylabel('Revenue Contribution (%)')
plt.show()
data['Ad_Efficiency'] = data['Revenue'] / data['Ad_Spend']
plt.figure(figsize=(10, 5))
sns.boxplot(data=data, x='Category', y='Ad_Efficiency')
plt.title('Ad Spend Efficiency by Category')
plt.xlabel('Category')
plt.ylabel('Revenue per Unit of Ad Spend')
plt.show()
plt.figure(figsize=(10, 5))
sns.histplot(data['Units_Sold'], bins=20, kde=True)
plt.title('Distribution of Units Sold')
plt.xlabel('Units Sold')
plt.ylabel('Frequency')
plt.show()
plt.figure(figsize=(10, 5))
sns.scatterplot(x=data['Units_Sold'], y=data['Revenue'])
plt.title('Units Sold vs Revenue')
plt.xlabel('Units Sold')
plt.ylabel('Revenue')
plt.show()
units_by_category = data.groupby('Category')['Units_Sold'].sum()
plt.figure(figsize=(10, 5))
units_by_category.plot(kind='bar')
plt.title('Units Sold by Category')
plt.xlabel('Category')
plt.ylabel('Units Sold')
plt.show()
data['Revenue_per_Impression'] = data['Revenue'] / data ['Impressions'].astype(float)
plt.figure(figsize=(10, 5))
sns.boxplot(data=data, x='Category', y='Revenue_per_Impression')
plt.title('Revenue per Impression by Category')
plt.xlabel('Category')
plt.ylabel('Revenue per Impression')
plt.show() |