/ Python And R Data science skills: 67 ECommerse csv Qustions Part 03

Friday, 16 February 2018

67 ECommerse csv Qustions Part 03

67 ECommerse csv Qustions Part 03
In [1]:
#ecom = pd.read_csv('Ecommerce.csv')
import pandas as pd
ecom=pd.read_csv("Ecommerce.csv")

Hard: How many people have a credit card that expires in 2025?

In [44]:
ecom['CC Exp Date'].iloc[0][3:]
Out[44]:
'20'
In [47]:
sum(ecom['CC Exp Date'].apply(lambda X: X[3:]) == '25')
Out[47]:
1033
In [37]:
sum(ecom['CC Exp Date'].apply(lambda x: x[3:]) == '25')
Out[37]:
1033
In [6]:
ecom['CC Exp Date'].apply(lambda x: x[3:]).head(5)
Out[6]:
0    20
1    18
2    19
3    24
4    25
Name: CC Exp Date, dtype: object
In [8]:
ecom['CC Exp Date'].head(1)
Out[8]:
0    02/20
Name: CC Exp Date, dtype: object
In [35]:
ecom['CC Exp Date'].iloc[0]
Out[35]:
'02/20'
In [36]:
ecom['CC Exp Date'].iloc[0][3:]
Out[36]:
'20'

Hard: What are the top 5 most popular email providers/hosts (e.g. gmail.com, yahoo.com, etc...)

ecom['Email'].apply(lambda x: x.split('@')[1]).value_counts().head(5)

In [53]:
ram=ecom["Email"].iloc[0]
ram.split('@')[1]
Out[53]:
'yahoo.com'
In [30]:
ecom["Email"].iloc[0]
Out[30]:
'pdunlap@yahoo.com'
In [31]:
ep=ecom["Email"].iloc[0]
In [32]:
ep.split('@')
Out[32]:
['pdunlap', 'yahoo.com']
In [33]:
ep.split('@')[1]
Out[33]:
'yahoo.com'
In [56]:
ecom['Email'].apply(lambda x: x.split('@')[1]).value_counts().head(5)
Out[56]:
hotmail.com     1638
yahoo.com       1616
gmail.com       1605
smith.com         42
williams.com      37
Name: Email, dtype: int64

No comments:

Post a Comment