antitheft159 commited on
Commit
057c157
·
verified ·
1 Parent(s): 5bb9e53

Upload tonal_159.py

Browse files
Files changed (1) hide show
  1. tonal_159.py +142 -0
tonal_159.py ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """tonal.159
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1d2iQuX1rG4rDuN_HjwOCnEStQRLaq-0V
8
+ """
9
+
10
+ import numpy as np
11
+ import pandas as pd
12
+ import os
13
+ import seaborn as sns
14
+ import matplotlib.pyplot as plt
15
+ import plotly.express as px
16
+ import pandas as pd
17
+
18
+ import missingno as msno
19
+
20
+ import warnings
21
+ warnings.filterwarnings('ignore')
22
+
23
+ df = pd.read_csv("/content/ecommerce_sales_analysis.csv")
24
+ df.head()
25
+
26
+ df.tail()
27
+
28
+ df.shape
29
+
30
+ df.info()
31
+
32
+ df.describe().T
33
+
34
+ df.describe().T.plot(kind='bar')
35
+
36
+ df.isnull().sum()
37
+
38
+ sns.heatmap(df.isnull())
39
+
40
+ df.duplicated().sum()
41
+
42
+ numeric_df = df.select_dtypes(include=['number'])
43
+
44
+ plt.figure(figsize=(12, 6))
45
+ sns.heatmap(numeric_df.corr(), annot=True, cmap='coolwarm')
46
+ plt.title('Correlation Heatmap')
47
+ plt.show()
48
+
49
+ df.columns.to_list()
50
+
51
+ import plotly.express as px
52
+
53
+ columns = ['product_id',
54
+ 'product_name',
55
+ 'category',
56
+ 'price',
57
+ 'review_score',
58
+ 'review_count',
59
+ 'sales_month_1',
60
+ 'sales_month_2',
61
+ 'sales_month_3',
62
+ 'sales_month_4',
63
+ 'sales_month_5',
64
+ 'sales_month_6',
65
+ 'sales_month_7',
66
+ 'sales_month_8',
67
+ 'sales_month_9',
68
+ 'sales_month_10',
69
+ 'sales_month_11',
70
+ 'sales_month_12',]
71
+
72
+ for column in columns:
73
+
74
+ if df[column].dtype == 'object' or df[column].dtype == 'category':
75
+ column_counts = df[column].value_counts().reset_index()
76
+ column_counts.columns = [column, 'count']
77
+
78
+ fig = px.bar(
79
+ column_counts,
80
+ x=column,
81
+ y='count',
82
+ title=f'Distribution of {column}',
83
+ labels={column: column, 'count': 'Count'},
84
+ text='count'
85
+ )
86
+
87
+ fig.update_layout(
88
+ xaxis_title=column,
89
+ yaxis_title='Count',
90
+ paper_bgcolor='rgba(0,0,0,0)',
91
+ plot_bgcolor='rgba(0,0,0,0)',
92
+ title_font=dict(size=18, family="Arial"),
93
+
94
+ xaxis={'categoryorder':'total descending'}
95
+ )
96
+
97
+ fig.show()
98
+
99
+ elif df[column].dtype == 'int64' or df[column].dtype == 'float64':
100
+
101
+ fig = px.histogram(
102
+ df,
103
+ x=column,
104
+ title=f'Distribution of {column}',
105
+ labels={column: column, 'count': 'Count'},
106
+
107
+ )
108
+
109
+ fig.update_layout(
110
+ xaxis_title=column,
111
+ yaxis_title='Count',
112
+ paper_bgcolor='rgba(0,0,0,0)',
113
+ plot_bgcolor='rgba(0,0,0,0)',
114
+ title_font=dict(size=18, family="Arial")
115
+ )
116
+
117
+ fig.show()
118
+
119
+ df
120
+
121
+ import matplotlib.pyplot as plt
122
+ from wordcloud import WordCloud, STOPWORDS
123
+ from collections import Counter
124
+ import pandas as pd
125
+
126
+ stop_words_list = set(STOPWORDS)
127
+
128
+ counts = Counter(df["category"].dropna().apply(lambda x: str(x)))
129
+
130
+ wcc = WordCloud(
131
+ background_color="black",
132
+ width=1600, height=800,
133
+ max_words=2000,
134
+ stopwords=stop_words_list
135
+ )
136
+ wcc.generate_from_frequencies(counts)
137
+
138
+ plt.figure(figsize=(10, 5), facecolor='k')
139
+ plt.imshow(wcc, interpolation='bilinear')
140
+ plt.axis("off")
141
+ plt.tight_layout(pad=0)
142
+ plt.show()