CoCalc Public Files05-17 (C.Y).ipynbOpen with one click!
Author: C Y
Views : 103
Compute Environment: Ubuntu 20.04 (Default)
In [3]:
import pandas as pd
In [4]:
df=pd.read_excel('SampleData.xlsx')
In [5]:
df.head()
OrderDate Region Rep Item Units Unit Cost Total
0 2016-01-06 East Jones Pencil 95 1.99 189.05
1 2016-01-23 Central Kivell Binder 50 19.99 999.50
2 2016-02-09 Central Jardine Pencil 36 4.99 179.64
3 2016-02-26 Central Gill Pen 27 19.99 539.73
4 2016-03-15 West Sorvino Pencil 56 2.99 167.44
In [6]:
df_Central=df[df['Region']=='Central']
In [7]:
df[df['Region']=='Central']
OrderDate Region Rep Item Units Unit Cost Total
1 2016-01-23 Central Kivell Binder 50 19.99 999.50
2 2016-02-09 Central Jardine Pencil 36 4.99 179.64
3 2016-02-26 Central Gill Pen 27 19.99 539.73
6 2016-04-18 Central Andrews Pencil 75 1.99 149.25
7 2016-05-05 Central Jardine Pencil 90 4.99 449.10
10 2016-06-25 Central Morgan Pencil 90 4.99 449.10
14 2016-09-01 Central Smith Desk 2 125.00 250.00
16 2016-10-05 Central Morgan Binder 28 8.99 251.72
19 2016-11-25 Central Kivell Pen Set 96 4.99 479.04
20 2016-12-12 Central Smith Pencil 67 1.29 86.43
22 2017-01-15 Central Gill Binder 46 8.99 413.54
23 2017-02-01 Central Smith Binder 87 15.00 1305.00
26 2017-03-24 Central Jardine Pen Set 50 4.99 249.50
27 2017-04-10 Central Andrews Pencil 66 1.99 131.34
29 2017-05-14 Central Gill Pencil 53 1.29 68.37
30 2017-05-31 Central Gill Binder 80 8.99 719.20
31 2017-06-17 Central Kivell Desk 5 125.00 625.00
33 2017-07-21 Central Morgan Pen Set 55 12.49 686.95
34 2017-08-07 Central Kivell Pen Set 42 23.95 1005.90
36 2017-09-10 Central Gill Pencil 7 1.29 9.03
39 2017-10-31 Central Andrews Pencil 14 1.29 18.06
40 2017-11-17 Central Jardine Binder 11 4.99 54.89
41 2017-12-04 Central Jardine Binder 94 19.99 1879.06
42 2017-12-21 Central Andrews Binder 28 4.99 139.72
In [11]:
df_central_Binder= df_Central[df['Item']=='Binder']
<ipython-input-11-72ceddacb099>:1: UserWarning: Boolean Series key will be reindexed to match DataFrame index. df_central_Binder= df_Central[df['Item']=='Binder']
In [12]:
df_central_Binder
OrderDate Region Rep Item Units Unit Cost Total
1 2016-01-23 Central Kivell Binder 50 19.99 999.50
16 2016-10-05 Central Morgan Binder 28 8.99 251.72
22 2017-01-15 Central Gill Binder 46 8.99 413.54
23 2017-02-01 Central Smith Binder 87 15.00 1305.00
30 2017-05-31 Central Gill Binder 80 8.99 719.20
40 2017-11-17 Central Jardine Binder 11 4.99 54.89
41 2017-12-04 Central Jardine Binder 94 19.99 1879.06
42 2017-12-21 Central Andrews Binder 28 4.99 139.72
In [13]:
df_central_Binder['Units'].sum()
424
In [ ]: