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
import requests | |
from bs4 import BeautifulSoup | |
page = requests.get("http://nplus1.ru/") | |
soup = BeautifulSoup(page.text) | |
links_raw = soup.find_all("a") | |
links_all = [] | |
for link in links_raw: | |
links_all.append(link["href"]) |
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
# !pip install selenium | |
from selenium import webdriver as wd | |
br = wd.Chrome("/Users/allat/Downloads/chromedriver") | |
br.get("http://www.biblio-globus.ru/") | |
search = br.find_element_by_id("search_string") | |
search = br.find_element_by_id("search_string") | |
search.send_keys("Python") |
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
import requests | |
from bs4 import BeautifulSoup | |
page = requests.get("https://nplus1.ru/") | |
soup = BeautifulSoup(page.text) | |
raw_links = soup.find_all("a") | |
news = [] | |
for link in raw_links: |
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
numbers = [1, 0, 3, -5, 9, -8, -10, -12, 3, 7, 8] | |
if numbers[0] > 0: | |
print("Yes") | |
else: | |
print("No") | |
if numbers[0] > 0: | |
print("Yes") |
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
### installing and loading packages ### | |
install.packages("rvest") | |
library(rvest) | |
library(tidyverse) | |
### parsing HTML ### | |
# read HTML by link |
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
# dataset | |
View(USJudgeRatings) | |
# Pearson correlation | |
cor.test(USJudgeRatings$FAMI, USJudgeRatings$DECI) | |
# Spearman correlation |
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
get_news <- function(link1){ | |
page1 <- read_html(link1) | |
page1 %>% html_nodes(".table") | |
tables <- page1 %>% html_nodes(xpath = "//p[@class='table']") | |
rubs <- tables[1] %>% html_nodes("a") %>% html_text() | |
time <- tables[2] %>% html_nodes("time") | |
date <- time %>% html_attr("content") | |
date_unix <- time %>% html_attr("data-unix") | |
time_human <- time %>% html_node("span") %>% html_text() | |
diffc <- tables[3] %>% html_node(".difficult-value") %>% |
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
# choose color | |
scat <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, | |
type = "scatter", mode = "markers", | |
marker = list(color = "blue")) | |
scat <- scat %>% layout(title = list(text = "<b>Iris Data</b>"), | |
updatemenus = list(list(x = -0.5, | |
y = 4, | |
buttons = list( |
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
## PART 1: PROPORTIONS ## | |
### COUNT DATA ### | |
girls <- read.csv("https://allatambov.github.io/twimc/names-girls.csv") | |
boys <- read.csv("https://allatambov.github.io/twimc/names-boys.csv") | |
girls <- girls[girls$Month == "январь" & girls$Year == 2018, ] | |
table(girls$Name) |
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
install.packages("tidyverse") | |
library(tidyverse) | |
anames <- read.csv("https://allatambov.github.io/twimc/names.csv", encoding = "UTF-8") | |
names18 <- anames %>% filter(Year == 2018 & Month == "январь") | |
names18_f <- names18 %>% filter(Sex == "female") | |
names18_m <- names18 %>% filter(Sex == "male") |