-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathproject 1.py
More file actions
250 lines (91 loc) · 2.33 KB
/
project 1.py
File metadata and controls
250 lines (91 loc) · 2.33 KB
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import pandas as pd
# In[2]:
data = pd.read_csv('Ecommerce Purchases')
data
# In[3]:
data.head(10)
# In[4]:
data.tail(10)
# In[5]:
data.dtypes
# In[6]:
data.isnull()
# In[7]:
data.columns
# In[8]:
len(data.columns)
# In[9]:
len(data)
# In[10]:
data.info()
# In[11]:
data.columns
# In[13]:
data['Purchase Price'].max()
# In[14]:
data['Purchase Price'].min()
# In[16]:
# AVERAGE PURCHASE PRICE
data['Purchase Price'].mean()
# In[17]:
#HOW MANY PEOPLE HAS FRENCH AS THEIR LANGUAGE
data[data['Language']=='fr']
# In[18]:
len(data[data['Language']=='fr'])
# In[19]:
data[data['Language']=='fr'].count()
# In[24]:
#JOB TITLE CONTAINS ENGINEER
data[data['Job'].str.contains('engineer', case = False)]
# In[25]:
len(data[data['Job'].str.contains('engineer', case = False)])
# In[26]:
# FIND EMAIL OF THE PERSON WITH THE FOLLOWING ADRESS 132.207.160.22
data.columns
# In[36]:
data[data['IP Address']=="132.207.160.22"]['Email']
# In[42]:
#How many people have mastercard as their credit card provider and made a purchase above 50
data[(data['CC Provider']=="Mastercard") & (data['Purchase Price']>50)]
# In[44]:
len(data[(data['CC Provider']=="Mastercard") & (data['Purchase Price']>50)])
data[(data['CC Provider']=="Mastercard") & (data['Purchase Price']>50)].count
# In[46]:
# FIND EMAIL OF THE PERSON WITH TH FOLL CREDIT NUMBER 4664825258997302
data.columns
# In[56]:
data[data['Credit Card']==4664825258997302]['Email']
# In[57]:
# HOW MANY PEOPLE pURCHASE DURING AM AND HOW MANY DURING PM
data.columns
# In[61]:
data['AM or PM'].value_counts()
# In[63]:
#HOW MANY PEOPLE HAVE A CREDIT CARD THAT WILL EXPIRE IN 2020
data['CC Exp Date']
# In[77]:
def fun():
count = 0
for date in data['CC Exp Date']:
if date.split('/')[1] == '20':
count = count + 1
print(count)
# In[78]:
fun()
# In[83]:
len(data[data['CC Exp Date'].apply(lambda x: x[3:]=='20')])
# In[84]:
#TOP 5 MOST POPULAR EMAIL PROVIDER
list1 = []
for email in data['Email']:
list1.append(email.split('@')[1])
# In[97]:
data['popular'] = list1
# In[102]:
data['popular'].value_counts().head(5)
# In[104]:
data['Email'].apply(lambda x: x.split('@')[1]).value_counts().head(5)
# In[ ]: