-
Notifications
You must be signed in to change notification settings - Fork 0
/
propanda.py
133 lines (65 loc) · 2.03 KB
/
propanda.py
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
#!/usr/bin/env python
# coding: utf-8
# # Project Pandas :
# In[1]:
# import pandas
import pandas as pd
import numpy as np
# In[2]:
# load the data
data = pd.read_csv('Ecom')
data.head()
# 1. Display Top 10 Rows of The Dataset
# In[3]:
data.head(10)
# 2. Check Last 10 Rows of The Dataset
# In[4]:
data.tail(10)
# 3. Check Datatype of Each Column
# In[5]:
data.info()
# 4. Check null values in the dataset
# In[6]:
data.isna()
# 5. How many rows and columns are there in our Dataset?
# In[7]:
print(len(data.columns),len(data))
# 6. Highest and Lowest Purchase Prices.
# In[8]:
print(min(data['Purchase Price']),max(data['Purchase Price']))
# 7. Average Purchase Price
# In[34]:
data['Purchase Price'].mean()
# 8. How many people have French 'fr' as their Language
# In[20]:
data['Language'].isin(['fr']).sum(axis=0)
# In[21]:
len(data[data['Language']=='fr'])
# 9. Job Title Contains Engineer
# In[24]:
len(data[data['Job'].str.contains('engineer',case=False)])
# 10. Find The Email of the person with the following IP Address: 132.207.160.22
# In[27]:
data[data['IP Address']=='132.207.160.22']['Email']
# 11. How many People have Mastercard as their Credit Card Provider and made a purchase above 50
# In[62]:
len(data[(data['CC Provider']=='Mastercard') & (data['Purchase Price']>50)])
# 12. Find the email of the person with the following Credit Card Number: 4664825258997302
# In[64]:
data[data['Credit Card']==4664825258997302]['Email']
# 13. How many people purchase during the AM and how many people purchase during PM?
# In[70]:
data['AM or PM'].value_counts()
# 14. How many people have a credit card that expires in 2020?
# In[80]:
len(data[data['CC Exp Date'].str.contains('/20')])
# 15. What are the top 5 most popular email providers (e.g. gmail.com, yahoo.com, etc...)
# In[94]:
list=[]
for e in data['Email']:
list.append(e.split('@')[1])
data['temp']=list
data['temp'].value_counts().head()
# In[95]:
data['Email'].apply(lambda x : x.split('@')[1]).value_counts().head()
# In[ ]: