column 0 = year, column 1 = month, column 2 = day
data = pd.read_csv('./wind.data', sep='\s+', parse_dates=[[0, 1, 2]])
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Problem 1.1 | |
### You have an N-element tuple or sequence that you would like to unpack into a collection of N variables. | |
``` | |
p = (4, 5) | |
x, y = p # x = 4, y = 5 | |
``` | |
## Problem 1.2 | |
#### You need to unpack N elements from an iterable, but the iterable may be longer than N elements, causing a “too many values to unpack” exception. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Defining and initializing vectors | |
vector<T> v1; // vector that holds object of type T, default constructor v1 is empty | |
vector<T> v2 (v1); // v2 is a copy of v1 | |
vector<T> v3(n, i); // v2 has n elements with value i | |
vector<T> v4(n); // v4 has n copies of a value-initialized object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
college_data_processed <- college_data_processed %>% | |
group_by(STATENAME) %>% | |
mutate_at(vars(-UNITID:-REGION, -INSTNM), ~ifelse(is.na(.x), mean(.x, na.rm = TRUE), .x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Notes | |
grand_slam_ages <- player_dob %>% | |
select(name, date_of_birth) %>% | |
inner_join(grand_slams, by = "name") %>% | |
mutate(age = as.numeric(difftime(tournament_date, date_of_birth, unit = "days") / 365.25)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grand_slam_ages %>% | |
mutate(decade = 10 * (year %/% 10)) %>% | |
ggplot(aes(decade, age, fill = gender, group = interaction(decade, gender))) + | |
geom_boxplot() + | |
scale_x_continuous(breaks = seq(1950, 2021, 10)) + | |
expand_limits(x = 2020) |
NewerOlder