Welcome to the world of data science
Throughout the world of data science, there are many languages and tools that can be used to complete a given task. While you are often able to use whichever tool you prefer, it is often important for analysts to work with similar platforms so that they can share their code with one another. Learning what professionals in the data science industry use while at work can help you gain a better understanding of things that you may be asked to do in the future.
In this project, we are going to find out what tools and languages professionals use in their day-to-day work. Our data comes from the Kaggle Data Science Survey which includes responses from over 10,000 people that write code to analyze data in their daily work.
Setup
# Loading necessary packages
library(tidyverse)
## ── Attaching packages ────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.1.0 ✔ purrr 0.2.5
## ✔ tibble 1.4.2 ✔ dplyr 0.7.7
## ✔ tidyr 0.8.2 ✔ stringr 1.3.1
## ✔ readr 1.1.1 ✔ forcats 0.3.0
## ── Conflicts ───────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
# Loading the data
responses <- read_csv("datasets/kagglesurvey.csv")
## Parsed with column specification:
## cols(
## Respondent = col_integer(),
## WorkToolsSelect = col_character(),
## LanguageRecommendationSelect = col_character(),
## EmployerIndustry = col_character(),
## WorkAlgorithmsSelect = col_character()
## )
## # A tibble: 10 x 5
## Respondent WorkToolsSelect LanguageRecomme… EmployerIndustry
## <int> <chr> <chr> <chr>
## 1 1 Amazon Web ser… F# Internet-based
## 2 2 Amazon Machine… Python Mix of fields
## 3 3 C/C++,Jupyter … Python Technology
## 4 4 Jupyter notebo… Python Academic
## 5 5 C/C++,Cloudera… R Government
## 6 6 SQL Python Non-profit
## 7 7 Jupyter notebo… Python Internet-based
## 8 8 Python,Spark /… Python Mix of fields
## 9 9 Jupyter notebo… Python Financial
## 10 10 C/C++,IBM Cogn… R Technology
## # ... with 1 more variable: WorkAlgorithmsSelect <chr>
2. Using multiple tools
Now that we’ve loaded in the survey results, we want to focus on the tools and languages that the survey respondents use at work.
## [1] "Amazon Web services,Oracle Data Mining/ Oracle R Enterprise,Perl"
# Creating a new data frame called tools
tools <- responses
# Adding a new column to tools which splits the WorkToolsSelect column at the commas and unnests the new column
tools <- tools %>%
mutate(work_tools = strsplit(WorkToolsSelect, ",")) %>%
unnest(work_tools)
# Viewing the first 6 rows of tools
head(tools)
## # A tibble: 6 x 6
## Respondent WorkToolsSelect LanguageRecomme… EmployerIndustry
## <int> <chr> <chr> <chr>
## 1 1 Amazon Web ser… F# Internet-based
## 2 1 Amazon Web ser… F# Internet-based
## 3 1 Amazon Web ser… F# Internet-based
## 4 2 Amazon Machine… Python Mix of fields
## 5 2 Amazon Machine… Python Mix of fields
## 6 2 Amazon Machine… Python Mix of fields
## # ... with 2 more variables: WorkAlgorithmsSelect <chr>, work_tools <chr>
3. Counting users of each tool
Now that we’ve split apart all of the tools used by each respondent, we can figure out which tools are the most popular.
# Creating a new data frame
tool_count <- tools
# Grouping the data by work_tools, calculate the number of responses in each group
tool_count <- tool_count %>%
group_by(work_tools) %>%
summarise(count = n()) %>%
# Sorting tool_count so that the most popular tools are at the top
arrange(desc(count))
# Printing the first 6 results
head(tool_count)
## # A tibble: 6 x 2
## work_tools count
## <chr> <int>
## 1 Python 6073
## 2 R 4708
## 3 SQL 4261
## 4 Jupyter notebooks 3206
## 5 TensorFlow 2256
## 6 <NA> 2198
4. Plotting the most popular tools
Let’s see how your favorite tools stack up against the rest.
# Creating a bar chart of the work_tools column.
# Arranging the bars so that the tallest are on the far right
ggplot(tool_count, aes(x = reorder(work_tools, count),
y = count)) +
geom_bar(stat = "identity",
aes(fill = work_tools)) +
# Adding non basic-cosmetic theme
theme_fivethirtyeight() +
# Rotating the bar labels 90 degrees
theme(axis.text.x = element_text(angle = 90,
vjust = 0.5,
hjust = 1)) +
labs(title = "The Most Popular Tools in Data Science",
x = "Tools",
y = "Count") +
theme(legend.position="none")
5. The R vs Python debate
Within the field of data science, there is a lot of debate among professionals about whether R or Python should reign supreme. You can see from our last figure that R and Python are the two most commonly used languages, but it’s possible that many respondents use both R and Python. Let’s take a look at how many people use R, Python, and both tools.
# Creating a new data frame called debate_tools
debate_tools <- responses
# Creating a new column called language preference, based on the conditions specified in the Instructions
debate_tools <- debate_tools %>%
mutate(language_preference = case_when(
grepl("R", WorkToolsSelect) & ! grepl("Python", WorkToolsSelect) ~ "R",
! grepl("R", WorkToolsSelect) & grepl("Python", WorkToolsSelect) ~ "Python",
grepl("R", WorkToolsSelect) & grepl("Python", WorkToolsSelect) ~ "both",
! grepl("R", WorkToolsSelect) & ! grepl("Python", WorkToolsSelect) ~ "neither"))
# Printing the first 6 rows
head(debate_tools)
## # A tibble: 6 x 6
## Respondent WorkToolsSelect LanguageRecomme… EmployerIndustry
## <int> <chr> <chr> <chr>
## 1 1 Amazon Web ser… F# Internet-based
## 2 2 Amazon Machine… Python Mix of fields
## 3 3 C/C++,Jupyter … Python Technology
## 4 4 Jupyter notebo… Python Academic
## 5 5 C/C++,Cloudera… R Government
## 6 6 SQL Python Non-profit
## # ... with 2 more variables: WorkAlgorithmsSelect <chr>,
## # language_preference <chr>
6. Plotting R vs Python users
Now we just need to take a closer look at how many respondents use R, Python, and both!
# Creating a new data frame
debate_plot <- debate_tools
# Grouping by language preference and calculate number of responses
debate_plot <- debate_plot %>%
group_by(language_preference) %>%
summarise(count = n()) %>%
# Removing the row for users of "neither"
filter(language_preference != "neither")
# Creating a bar chart
ggplot(debate_plot, aes(x = language_preference,
y = count)) +
geom_bar(stat = "identity",
aes(fill = language_preference)) +
theme_fivethirtyeight() +
# Rotating the bar labels 90 degrees
theme(axis.text.x = element_text(vjust = 0.5,
hjust = 0.5)) +
labs(title = "The Most Popular Tools in Data Science",
x = "Tools", y = "Count")
7. Language recommendations
It looks like the largest group of professionals program in both Python and R. But what happens when they are asked which language they recommend to new learners? Do R lovers always recommend R?
# Creating a new data frame
recommendations <- debate_tools
# Grouping by language_preference and then LanguageRecommendationSelect
recommendations <- recommendations %>%
group_by(language_preference, LanguageRecommendationSelect) %>%
summarise(count = n()) %>%
# Removing empty responses and include the top recommendations
filter(LanguageRecommendationSelect != "NA") %>%
arrange(language_preference, desc(count)) %>%
mutate(row_no = row_number(language_preference)) %>%
filter(row_no <= 4)
recommendations
## # A tibble: 16 x 4
## # Groups: language_preference [4]
## language_preference LanguageRecommendationSelect count row_no
## <chr> <chr> <int> <int>
## 1 both Python 1917 1
## 2 both R 912 2
## 3 both SQL 108 3
## 4 both Scala 28 4
## 5 neither Python 196 1
## 6 neither R 94 2
## 7 neither SQL 53 3
## 8 neither Matlab 47 4
## 9 Python Python 1742 1
## 10 Python C/C++/C# 48 2
## 11 Python Matlab 43 3
## 12 Python SQL 36 4
## 13 R R 632 1
## 14 R Python 194 2
## 15 R SQL 75 3
## 16 R C/C++/C# 27 4
8. The most recommended language by the language used
Just one thing left. Let’s graphically determine which languages are most recommended based on the language that a person uses.
# Creating a faceted bar plot
ggplot(recommendations, aes(x = LanguageRecommendationSelect,
y = count)) +
geom_bar(stat = "identity",
aes(fill = LanguageRecommendationSelect)) +
facet_wrap(~ language_preference) +
theme_fivethirtyeight() +
theme(axis.text.x = element_text(angle = 90,
vjust = 0.5,
hjust = 0.5)) +
labs(title = "Language Recommendation for These Language Users",
x = "Tools", y = "Count")
9. The moral of the story
So we’ve made it to the end. We’ve found that Python is the most popular language used among Kaggle data scientists, but R users aren’t far behind. And while Python users may highly recommend that new learners learn Python, would R users find the following statement TRUE
or FALSE
?