Commit 46aa52c7 authored by George Mount's avatar George Mount
Browse files

clear out cell blocks and files

parent a7fe1175
......@@ -14,20 +14,11 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"7\n",
"<class 'int'>\n"
]
}
],
"outputs": [],
"source": [
"a = -10 + 2\n",
"b = abs(a)\n",
......@@ -53,20 +44,11 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['North', 'East', 'South', 'West']\n",
"6\n"
]
}
],
"outputs": [],
"source": [
"directions = ['North','East','South','West']\n",
"print(directions)\n",
......@@ -93,19 +75,11 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['Friday', 'Monday', 'Saturday', 'Sunday', 'Thursday', 'Tuesday', 'Wednesday']\n"
]
}
],
"outputs": [],
"source": [
"my_week = (['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'])\n",
"my_week.sort()\n",
......@@ -114,19 +88,11 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[]\n"
]
}
],
"outputs": [],
"source": [
"my_week.clear()\n",
"print(my_week)"
......@@ -143,21 +109,11 @@
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": null,
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[7, 12, 5]\n",
"[5, 10]\n",
"[12, 5, 10, 9]\n"
]
}
],
"outputs": [],
"source": [
"my_list = [7,12,5,10,9]\n",
"\n",
......@@ -184,19 +140,9 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['on', 'lists', 'of', 'strings', 'identically']\n",
"['Slicing', 'works', 'on', 'lists']\n",
"['strings', 'identically']\n"
]
}
],
"outputs": [],
"source": [
"this_list = [\"Slicing\",\"works\",\"on\",\"lists\",\"of\",\"strings\",\"identically\"]\n",
"\n",
......@@ -230,20 +176,9 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3628800"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"import math\n",
"\n",
......@@ -285,7 +220,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.7.9"
}
},
"nbformat": 4,
......
library(tidyverse)
library(readxl)
region_1 <- read_excel("C:/RFiles/sales_report.xlsx", sheet = "region_1")
head(region_1)
region_2 <- read_excel("C:/RFiles/sales_report.xlsx", sheet = "region_2")
head(region_2)
region_3 <- read_excel("C:/RFiles/sales_report.xlsx", sheet = "region_3")
head(region_3)
region_1 <- read_excel("C:/RFiles/sales_report.xlsx", sheet = "region_1")
head(region_1)
region_2 <- read_excel("C:/RFiles/sales_report.xlsx", sheet = "region_2")
head(region_2)
region_3 <- read_excel("C:/RFiles/sales_report.xlsx", sheet = "region_3")
head(region_3)
region_2$category <- str_to_title(region_2$category)
head(region_2)
# Region 3 -- add the region field
# Yes, just like this!
region_3$region <- 3
head(region_3)
sales_report <- bind_rows(region_1, region_2, region_3)
dim(sales_report)
# Did we get everything?
(nrow(region_1) + nrow(region_2) + nrow(region_3)) == nrow(sales_report)
head(sales_report)
sales_report %>%
group_by(category) %>%
summarise(avg_sales = mean(sales)) %>%
arrange(category)
sales_report %>%
group_by(region) %>%
summarise(total_sales = sum(sales)) %>%
arrange(desc(total_sales))
sales_report %>%
filter(region == 1 | region == 2) %>%
arrange(id) %>%
select(-region)
sales_report %>%
filter(region == 1 | region == 2) %>%
select(-region) %>%
arrange(id)
sales_report %>%
filter(region == 1 | region == 2) %>%
select(-region) %>%
arrange(id)
sales_report %>%
filter(region == 1 | region == 2) %>%
select(-region) %>%
arrange(id)
sales_report %>%
filter(region == 1 | region == 2) %>%
arrange(id) %>%
select(-region)
library(tidyverse)
library(Lahman)
# Players table is stored as Master
data("Master")
data("HallOfFame")
lahman_inner <- inner_join(Master, HallOfFame)
dim(lahman_inner)
dim(lahman_inner)
dim(Master)
dim(HallOfFame)
# Spreadsheet viewing environment
View(lahman_inner)
# What if we just want some fields
inner_join(select(Master, nameFirst, nameLast), HallOfFame)
# What if we just want some fields
inner_join(select(Master, nameFirst, nameLast), HallOfFame)
dim(Master)
dim(HallOfFame)
# What if we just want some fields
inner_join(select(Master, nameFirst, nameLast), HallOfFame)
# Need to keep playerID in the running!
inner_join(select(Master, nameFirst, nameLast, playerID), HallOfFame)
# Compare to left join
lahman_left <- left_join(Master, HallOfFame)
dim(lahman_left)
# Compare to inner join
dim(lahman_inner)
# See the NULLs
View(lahman_left)
library(tidyverse)
library(Lahman)
# Players table is stored as Master
data("Master")
data("HallOfFame")
lahman_inner <- inner_join(Master, HallOfFame)
dim(lahman_inner)
dim(Master)
dim(HallOfFame)
# Spreadsheet viewing environment
View(lahman_inner)
# What if we just want some fields
# this will bring an error --
inner_join(select(Master, nameFirst, nameLast), HallOfFame)
# Need to keep playerID in the running!
inner_join(select(Master, nameFirst, nameLast, playerID), HallOfFame)
# Ordering doesn't matter in inner join
dim(inner_join(HallOfFame, Master))
# Compare to left join
lahman_left <- left_join(Master, HallOfFame)
dim(lahman_left)
# Compare to inner join
dim(lahman_inner)
# See the NULLs
View(lahman_left)
# What about the other way?
lahman_left_other <- left_join(HallOfFame, Master)
dim(lahman_left_other)
# What about the other way?
lahman_left_other <- left_join(HallOfFame, Master)
dim(lahman_left_other)
library(tidyverse)
library(Lahman)
data("Managers")
data("AwardsManagers")
inner_join(Managers, AwardsManagers)
ncol(Managers)
ncol(AwardsManagers)
inner_join <- inner_join(Managers, AwardsManagers)
ncol(Managers)
ncol(AwardsManagers)
dim(inner_join)
names(Managers)
names(AwardsManagers)
# Return the join of records found in both tables.
# Keep all fields except Managers$rank.
inner_join_less_m <- inner_join(select(Managers, -rank), HallOfFame)
dim(inner_join_less_m)
# Return the join of records found in both tables.
# Keep all fields except Managers$rank.
inner_join_less_m <- inner_join(select(Managers, -rank), HallOfFame)
# Return the join of records found in both tables.
# Keep all fields except Managers$rank.
inner_join_less_m <- inner_join(select(Managers, -rank), HallOfFame)
dim(inner_join_less_m)
dim(inner_join)
dim(inner_join)
dim(inner_join_less_m)
head(Managers)
dim(Managers)
dim(select(Managers, -rank))
dim(Managers)
dim(select(Managers, -rank))
dim(Managers)
# Return the join of records found in both tables.
# Keep all fields except Managers$rank.
inner_join_less_m <- inner_join(select(Managers, -rank), AwardsManagers)
# Return the join of records found in both tables.
# Keep all fields except Managers$rank.
inner_join_less_m <- inner_join(select(Managers, -rank), AwardsManagers)
dim(inner_join_less_m)
dim(inner_join)
dim(inner_join_less_m)
# Return the join of records for all found in Managers.
left_join <- left_join(Master, HallOfFame)
dim(left_join)
nrow(Managers)
# Return the join of records for all found in Managers.
left_join <- left_join(Managers, AwardsManagers)
dim(left_join)
nrow(Managers)
# How many more rows does this have than the results of 1?
nrow(left_join(Managers, AwardsManagers)) - nrow(inner_join(Managers, AwardsManagers))
# How many more rows does this have than the results of 1?
nrow(left_join(Managers, AwardsManagers)) - nrow(inner_join(Managers, AwardsManagers))
# How many more rows does this have than the results of 1?
nrow(left_join(Managers, AwardsManagers)) - nrow(inner_join(Managers, AwardsManagers))
# How many more rows does this have than the results of 1?
nrow(left_join) - nrow(inner_join)
# Return the join of records for all found in Managers.
left_join <- left_join(Managers, AwardsManagers)
dim(left_join)
View(left_join)
nrow(AwardsManagers)
nrow(Managers)
nrow(left_join)
nrow(Managers)
nrow(left_join)
library(tidyverse)
library(Lahman)
data("Teams")
teams <- Teams
teams <- filter(teams, yearID >= 2000)
teams <- group_by(teams, teamID)
summarise(teams, mean = mean(W),
min = min(W),
max = max(W))
teams %>%
filter(yearID >= 2000) %>%
group_by(teamID) %>%
summarise(mean = mean(W),
min = min(W),
max = max(W))
teams %>%
filter(yearID >= 2000) %>%
group_by(teamID) %>%
summarise(mean = mean(W),
min = min(W),
max = max(W))
winning <- teams %>%
filter(yearID >= 2000) %>%
group_by(teamID) %>%
summarise(mean = mean(W),
min = min(W),
max = max(W)) %>%
arrange(desc(mean))
head(winning)
[.ShellClassInfo]
InfoTip=This folder is shared online.
IconFile=C:\Program Files\Google\Drive\googledrivesync.exe
IconIndex=16
\ No newline at end of file
region,id,channel,category,sales
1,197,1,Fresh ,30624
1,197,1,Milk ,7209
1,197,1,Grocery ,4897
1,197,1,Frozen ,18711
1,197,1,Deli ,2876
1,197,1,Detergents ,763
1,198,2,Fresh ,2427
1,198,2,Milk ,7097
1,198,2,Grocery ,10391
1,198,2,Frozen ,1127
1,198,2,Deli ,1468
1,198,2,Detergents ,4314
1,199,1,Fresh ,11686
1,199,1,Milk ,2154
1,199,1,Grocery ,6824
1,199,1,Frozen ,3527
1,199,1,Deli ,697
1,199,1,Detergents ,592
1,200,1,Fresh ,9670
1,200,1,Milk ,2280
1,200,1,Grocery ,2112
1,200,1,Frozen ,520
1,200,1,Deli ,347
1,200,1,Detergents ,402
1,201,2,Fresh ,3067
1,201,2,Milk ,13240
1,201,2,Grocery ,23127
1,201,2,Frozen ,3941
1,201,2,Deli ,731
1,201,2,Detergents ,9959
1,202,2,Fresh ,4484
1,202,2,Milk ,14399
1,202,2,Grocery ,24708
1,202,2,Frozen ,3549
1,202,2,Deli ,1681
1,202,2,Detergents ,14235
1,203,1,Fresh ,25203
1,203,1,Milk ,11487
1,203,1,Grocery ,9490
1,203,1,Frozen ,5065
1,203,1,Deli ,6854
1,203,1,Detergents ,284
1,204,1,Fresh ,583
1,204,1,Milk ,685
1,204,1,Grocery ,2216
1,204,1,Frozen ,469
1,204,1,Deli ,18
1,204,1,Detergents ,954
1,205,1,Fresh ,1956
1,205,1,Milk ,891
1,205,1,Grocery ,5226
1,205,1,Frozen ,1383
1,205,1,Deli ,1328
1,205,1,Detergents ,5
1,206,2,Fresh ,1107
1,206,2,Milk ,11711
1,206,2,Grocery ,23596
1,206,2,Frozen ,955
1,206,2,Deli ,710
1,206,2,Detergents ,9265
1,207,1,Fresh ,6373
1,207,1,Milk ,780
1,207,1,Grocery ,950
1,207,1,Frozen ,878
1,207,1,Deli ,285
1,207,1,Detergents ,288
1,208,2,Fresh ,2541
1,208,2,Milk ,4737
1,208,2,Grocery ,6089
1,208,2,Frozen ,2946
1,208,2,Deli ,120
1,208,2,Detergents ,5316
1,209,1,Fresh ,1537
1,209,1,Milk ,3748
1,209,1,Grocery ,5838
1,209,1,Frozen ,1859
1,209,1,Deli ,806
1,209,1,Detergents ,3381
1,210,2,Fresh ,5550
1,210,2,Milk ,12729
1,210,2,Grocery ,16767
1,210,2,Frozen ,864
1,210,2,Deli ,797
1,210,2,Detergents ,12420
1,211,1,Fresh ,18567
1,211,1,Milk ,1895
1,211,1,Grocery ,1393
1,211,1,Frozen ,1801
1,211,1,Deli ,2100
1,211,1,Detergents ,244
1,212,2,Fresh ,12119
1,212,2,Milk ,28326
1,212,2,Grocery ,39694
1,212,2,Frozen ,4736
1,212,2,Deli ,2870
1,212,2,Detergents ,19410
1,213,1,Fresh ,7291
1,213,1,Milk ,1012
1,213,1,Grocery ,2062
1,213,1,Frozen ,1291
1,213,1,Deli ,1775
1,213,1,Detergents ,240
1,214,1,Fresh ,3317
1,214,1,Milk ,6602
1,214,1,Grocery ,6861
1,214,1,Frozen ,1329
1,214,1,Deli ,1215
1,214,1,Detergents ,3961
1,215,2,Fresh ,2362
1,215,2,Milk ,6551
1,215,2,Grocery ,11364
1,215,2,Frozen ,913
1,215,2,Deli ,791
1,215,2,Detergents ,5957
1,216,1,Fresh ,2806
1,216,1,Milk ,10765
1,216,1,Grocery ,15538
1,216,1,Frozen ,1374
1,216,1,Deli ,2388
1,216,1,Detergents ,5828
1,217,2,Fresh ,2532
1,217,2,Milk ,16599
1,217,2,Grocery ,36486
1,217,2,Frozen ,179
1,217,2,Deli ,674
1,217,2,Detergents ,13308
1,218,1,Fresh ,18044
1,218,1,Milk ,1475
1,218,1,Grocery ,2046
1,218,1,Frozen ,2532
1,218,1,Deli ,1158
1,218,1,Detergents ,130
1,219,2,Fresh ,18
1,219,2,Milk ,7504
1,219,2,Grocery ,15205
1,219,2,Frozen ,1285
1,219,2,Deli ,6372
1,219,2,Detergents ,4797
1,220,1,Fresh ,4155
1,220,1,Milk ,367
1,220,1,Grocery ,1390
1,220,1,Frozen ,2306
1,220,1,Deli ,130
1,220,1,Detergents ,86
1,221,1,Fresh ,14755
1,221,1,Milk ,899
1,221,1,Grocery ,1382
1,221,1,Frozen ,1765
1,221,1,Deli ,749
1,221,1,Detergents ,56
1,222,1,Fresh ,5396
1,222,1,Milk ,7503
1,222,1,Grocery ,10646
1,222,1,Frozen ,91
1,222,1,Deli ,239
1,222,1,Detergents ,4167
1,223,1,Fresh ,5041
1,223,1,Milk ,1115
1,223,1,Grocery ,2856
1,223,1,Frozen ,7496
1,223,1,Deli ,375
1,223,1,Detergents ,256
1,224,2,Fresh ,2790
1,224,2,Milk ,2527
1,224,2,Grocery ,5265
1,224,2,Frozen ,5612
1,224,2,Deli ,1360
1,224,2,Detergents ,788
1,225,1,Fresh ,7274
1,225,1,Milk ,659
1,225,1,Grocery ,1499
1,225,1,Frozen ,784
1,225,1,Deli ,659
1,225,1,Detergents ,70
1,226,1,Fresh ,12680
1,226,1,Milk ,3243
1,226,1,Grocery ,4157
1,226,1,Frozen ,660
1,226,1,Deli ,786
1,226,1,Detergents ,761
1,227,2,Fresh ,20782
1,227,2,Milk ,5921
1,227,2,Grocery ,9212
1,227,2,Frozen ,1759
1,227,2,Deli ,1553
1,227,2,Detergents ,2568
1,228,1,Fresh ,4042
1,228,1,Milk ,2204
1,228,1,Grocery ,1563
1,228,1,Frozen ,2286
1,228,1,Deli ,689
1,228,1,Detergents ,263
1,229,1,Fresh ,1869
1,229,1,Milk ,577
1,229,1,Grocery ,572
1,229,1,Frozen ,950
1,229,1,Deli ,203
1,229,1,Detergents ,4762
1,230,1,Fresh ,8656
1,230,1,Milk ,2746
1,230,1,Grocery ,2501
1,230,1,Frozen ,6845
1,230,1,Deli ,980
1,230,1,Detergents ,694
1,231,2,Fresh ,11072
1,231,2,Milk ,5989
1,231,2,Grocery ,5615
1,231,2,Frozen ,8321
1,231,2,Deli ,2137