File size: 2,842 Bytes
057c157 |
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 |
# -*- coding: utf-8 -*-
"""tonal.159
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1d2iQuX1rG4rDuN_HjwOCnEStQRLaq-0V
"""
import numpy as np
import pandas as pd
import os
import seaborn as sns
import matplotlib.pyplot as plt
import plotly.express as px
import pandas as pd
import missingno as msno
import warnings
warnings.filterwarnings('ignore')
df = pd.read_csv("/content/ecommerce_sales_analysis.csv")
df.head()
df.tail()
df.shape
df.info()
df.describe().T
df.describe().T.plot(kind='bar')
df.isnull().sum()
sns.heatmap(df.isnull())
df.duplicated().sum()
numeric_df = df.select_dtypes(include=['number'])
plt.figure(figsize=(12, 6))
sns.heatmap(numeric_df.corr(), annot=True, cmap='coolwarm')
plt.title('Correlation Heatmap')
plt.show()
df.columns.to_list()
import plotly.express as px
columns = ['product_id',
'product_name',
'category',
'price',
'review_score',
'review_count',
'sales_month_1',
'sales_month_2',
'sales_month_3',
'sales_month_4',
'sales_month_5',
'sales_month_6',
'sales_month_7',
'sales_month_8',
'sales_month_9',
'sales_month_10',
'sales_month_11',
'sales_month_12',]
for column in columns:
if df[column].dtype == 'object' or df[column].dtype == 'category':
column_counts = df[column].value_counts().reset_index()
column_counts.columns = [column, 'count']
fig = px.bar(
column_counts,
x=column,
y='count',
title=f'Distribution of {column}',
labels={column: column, 'count': 'Count'},
text='count'
)
fig.update_layout(
xaxis_title=column,
yaxis_title='Count',
paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)',
title_font=dict(size=18, family="Arial"),
xaxis={'categoryorder':'total descending'}
)
fig.show()
elif df[column].dtype == 'int64' or df[column].dtype == 'float64':
fig = px.histogram(
df,
x=column,
title=f'Distribution of {column}',
labels={column: column, 'count': 'Count'},
)
fig.update_layout(
xaxis_title=column,
yaxis_title='Count',
paper_bgcolor='rgba(0,0,0,0)',
plot_bgcolor='rgba(0,0,0,0)',
title_font=dict(size=18, family="Arial")
)
fig.show()
df
import matplotlib.pyplot as plt
from wordcloud import WordCloud, STOPWORDS
from collections import Counter
import pandas as pd
stop_words_list = set(STOPWORDS)
counts = Counter(df["category"].dropna().apply(lambda x: str(x)))
wcc = WordCloud(
background_color="black",
width=1600, height=800,
max_words=2000,
stopwords=stop_words_list
)
wcc.generate_from_frequencies(counts)
plt.figure(figsize=(10, 5), facecolor='k')
plt.imshow(wcc, interpolation='bilinear')
plt.axis("off")
plt.tight_layout(pad=0)
plt.show() |