/ Python And R Data science skills: 65 ECommerse csv Qustions Part 01

Friday, 16 February 2018

65 ECommerse csv Qustions Part 01

https://vlrtraining.com/courses/python-data-science-beginner-tutorial 65 ECommerse csv Qustions Part 01
In [16]:
#import pandas as pd
#ecom = pd.read_csv('Ecommerce.csv')
import pandas as pd
ecom=pd.read_csv("Ecommerce.csv")
In [19]:
ecom.head(2)
Out[19]:
Address Lot AM or PM Browser Info Company Credit Card CC Exp Date CC Security Code CC Provider Email Job IP Address Language Purchase Price
0 16629 Pace Camp Apt. 448\nAlexisborough, NE 77... 46 in PM Opera/9.56.(X11; Linux x86_64; sl-SI) Presto/2... Martinez-Herman 6011929061123406 02/20 900 JCB 16 digit pdunlap@yahoo.com Scientist, product/process development 149.146.147.205 el 98.14
1 9374 Jasmine Spurs Suite 508\nSouth John, TN 8... 28 rn PM Opera/8.93.(Windows 98; Win 9x 4.90; en-US) Pr... Fletcher, Richards and Whitaker 3337758169645356 11/18 561 Mastercard anthony41@reed.com Drilling engineer 15.160.41.51 fr 70.73

How many rows and columns are there?

.col

index

len

info()

In [25]:
#ecom.info()
#len(ecom.columns)
len(ecom.index)
Out[25]:
10000

What is the average Purchase Price?

ecom['Purchase Price'].mean()

What were the highest and lowest purchase prices?

In [26]:
ecom.columns
Out[26]:
Index(['Address', 'Lot', 'AM or PM', 'Browser Info', 'Company', 'Credit Card',
       'CC Exp Date', 'CC Security Code', 'CC Provider', 'Email', 'Job',
       'IP Address', 'Language', 'Purchase Price'],
      dtype='object')
In [28]:
ecom["Purchase Price"].mean()
Out[28]:
50.34730200000025
In [29]:
ecom["Purchase Price"].min()
Out[29]:
0.0
In [30]:
ecom["Purchase Price"].max()
Out[30]:
99.989999999999995

How many people have English 'en' as their Language of choice on the website?

ecom[ecom['Language']=='en'].count()

ecom[ecom['Language']=='en'] [language].count()

In [45]:
#ecom.head(6)
#ecom[ecom["Language"]=='en']
#ecom[ecom["Language"]=='en'].head(4)
#sum(ecom["Language"]=='en')
ecom[ecom["Language"]=='en']["Language"].count()
Out[45]:
1098

How many people have the job title of "Lawyer" ?

ecom[ecom['Job'] == 'Lawyer'].info()

ecom[ecom['Job'] == 'Lawyer'].count()

len(ecom[ecom['Job'] == 'Lawyer'].count().index)

In [47]:
#ecom.head(6)
In [49]:
sum(ecom['Job']=='Lawyer')
Out[49]:
30
In [57]:
#ecom[ecom['Job']=='Lawyer'].info()
ecom[ecom['Job']=='Lawyer'].count()
Out[57]:
Address             30
Lot                 30
AM or PM            30
Browser Info        30
Company             30
Credit Card         30
CC Exp Date         30
CC Security Code    30
CC Provider         30
Email               30
Job                 30
IP Address          30
Language            30
Purchase Price      30
dtype: int64
In [52]:
len(ecom[ecom['Job']=='Lawyer'].info())
<class 'pandas.core.frame.DataFrame'>
Int64Index: 30 entries, 470 to 9979
Data columns (total 14 columns):
Address             30 non-null object
Lot                 30 non-null object
AM or PM            30 non-null object
Browser Info        30 non-null object
Company             30 non-null object
Credit Card         30 non-null int64
CC Exp Date         30 non-null object
CC Security Code    30 non-null int64
CC Provider         30 non-null object
Email               30 non-null object
Job                 30 non-null object
IP Address          30 non-null object
Language            30 non-null object
Purchase Price      30 non-null float64
dtypes: float64(1), int64(2), object(11)
memory usage: 3.5+ KB
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-52-efb5f544ba12> in <module>()
----> 1 len(ecom[ecom['Job']=='Lawyer'].info())

TypeError: object of type 'NoneType' has no len()

No comments:

Post a Comment