Hi community, Im want to access a data scraped with Py
code in Rmarkdwon but with R.
Im try with py.df1
but show error. Im want make a web scraping with Py
and make R
basics plots with Tidyverse.
---
title: "Scraping py"
author: "M.Acosta"
date: "`r Sys.Date()`"
output: html_document
---
```{r}
library(reticulate)
library(tidyverse)
import pandas as pd
import requests
from io import StringIO
url = "https://fbref.com/en/comps/9/keepers/Premier-League-Stats"
# Send a GET request and remove the comment tags from response text
stripped_comment_tags = StringIO(requests.get(url).text.replace('<!--', '').replace('-->', ''))
df1 = pd.read_html(stripped_comment_tags, attrs={'id': 'stats_squads_keeper_for'})[0]
df2 = pd.read_html(stripped_comment_tags, attrs={'id': 'stats_keeper'})[0]
# Print data frames
print(df1) # run well
print(df2) # run well
datos = py$df1 # Error
#datos = py$df1 Error: object 'py' not found
Tnks!