Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Kasidis Satangmongkol toyeiei

🎯
Focusing
View GitHub Profile
View stock_exercise.py
## I've tried below codes and all failed the test
## none of these worked ..
stock = stock.drop_duplicates('item')
stock = stock.drop_duplicates('item').reset_index()
stock = stock.drop_duplicates('item').reset_index(drop=True)
stock = stock.drop_duplicates(['item'])
stock = stock.drop_duplicates(['item']).reset_index()
stock = stock.drop_duplicates(['item']).reset_index(drop=True)
stock = stock['item'].drop_duplicates()
stock = stock['item'].drop_duplicates().reset_index()
@toyeiei
toyeiei / techjam_data_prep.R
Last active Nov 22, 2019
TECHJAM 2019 data preparation
View techjam_data_prep.R
## -------------------------------------
## Import Libraries --------------------
## -------------------------------------
library(dplyr)
library(readr)
library(lubridate)
library(tidyr)
library(DescTools)
## load dataset
@toyeiei
toyeiei / kfold_regression.R
Created Nov 15, 2019
train linear regression in R using kfold method
View kfold_regression.R
## R version 3.6.1
## Created by DataRockie 15 November 2019
## load library
library(caret)
library(mlbench)
library(dplyr)
## load dataset
data("BostonHousing")
View intro-web-html.html
<html>
<head>
<title>This is my first webpage</title>
</head>
<body>
<h1>Hello World</h1>
<p>Let's learn web development in two months.</p>
</body>
</html>
@toyeiei
toyeiei / covariance_correlation.R
Last active Sep 3, 2019
cov cor r-squared in R
View covariance_correlation.R
## create example data
x <- 1:20
y <- 35 + 5.5*x
## add some random noise to y
set.seed(99)
y <- y + rnorm(n = 20, mean = 2, sd = 5)
## create a data frame of xy
df <- data.frame(distance = x, fare = y)
@toyeiei
toyeiei / excel_data_transformation.R
Last active Aug 15, 2019
R4Excel - data transformation
View excel_data_transformation.R
## select columns
df %>%
select(id, student_name, gender)
## filter rows
df %>%
select(id, student_name, gender) %>%
filter(gender == "M")
## sample rows n=30
@toyeiei
toyeiei / excel_basic_charts.R
Created Aug 15, 2019
R4Excel - basic graphics
View excel_basic_charts.R
## histogram
hist(df$age, breaks = 3)
## barplot
barplot(table(df$nationality))
## scatter plot
plot(df$age, df$gpa, pch = 16)
@toyeiei
toyeiei / excel_pivot_table.R
Created Aug 15, 2019
R4Excel - pivot table in R
View excel_pivot_table.R
## count gender i.e. number of male and female students
df %>%
count(gender)
## count grouped gender and nationality
df %>%
count(gender, nationality)
## compute average age by gender group i.e. male age vs. female age
df %>%
@toyeiei
toyeiei / excel_vloopup.R
Last active Aug 15, 2019
R4Excel - vlookup in R
View excel_vloopup.R
## read a lookup table into R
lookup_state <- read.csv("lookup_table.csv")
## filter only US students
df_us <- filter(df, nationality == "US")
## we can use left_join to do vlookup in R
df_us %>%
left_join(lookup_state, by = c("id" = "us_students")) %>%
slice(1:10)
@toyeiei
toyeiei / excel_vloopup.R
Created Aug 15, 2019
R4Excel - vlookup in R
View excel_vloopup.R
## read a lookup table into R
lookup_state <- read.csv("lookup_table.csv")
## we can use left_join to do vlookup in R
df_us <- filter(df, nationality == "US")
df_us %>%
left_join(lookup_state, by = c("id" = "us_students")) %>%
slice(1:10)
You can’t perform that action at this time.