我的tbl_df:
> p2p_dt_SKILL_A%>%
+ select(Patch,Date,Prod_DL)%>%
+ head()
Patch Date Prod_DL
1 P1 2015-09-04 3.43
2 P11 2015-09-11 3.49
3 P12 2015-09-18 3.45
...
4 P13 2015-12-06 3.57
5 P14 2015-12-13 3.43
6 P15 2015-12-20 3.47
Run Code Online (Sandbox Code Playgroud)
我想rows根据日期选择所有,例如,如果Date大于2015-09-04和小于2015-09-18
结果应该是:
Patch Date Prod_DL
P1 2015-09-04 3.43
P11 2015-09-11 3.49
Run Code Online (Sandbox Code Playgroud)
我尝试了以下但它返回空的空向量.
p2p_dt_SKILL_A%>%
select(Patch,Date,Prod_DL)%>%
filter(Date > "2015-09-04" & Date <"2015-09-18")
Run Code Online (Sandbox Code Playgroud)
回报:
> p2p_dt_SKILL_A%>%
+ select(Patch,Date,Prod_DL)%>%
+ filter(Date > 2015-09-12 & Date <2015-09-18)
Source: local data table [0 x …Run Code Online (Sandbox Code Playgroud) 我的数据:
structure(list(LoB = c("C", "C", "C", "A",
"A", "B", "C", "A", "A", "C",
"A", "B", "C", "B", "A", "C", "B",
"A", "B", "C", "A", "B", "B", "A",
"B", "C", "A", "B", "C", "B"), word = c("speed",
"connection", "call", "bt", "reliable", "reliable", "reliable",
"expensive", "cheaper", "uk", "customer", "customer", "customer",
"network", "broadband", "broadband", "signal", "price", "price",
"price", "poor", "poor", "ee", "service", "service", "service",
"excellent", "excellent", "excellent", "coverage"), word_total = c(68L,
46L, 44L, 3138L, 3479L, 906L, 71L, 6096L, 2967L, 39L, 10405L,
1429L, 113L, …Run Code Online (Sandbox Code Playgroud) 我试图使用str_detect,str_replace,str_replace_all在方法dbplyr与oracle作为beckend数据库,但似乎无法访问此方法。
这是错误:
db_tbl %>% mutate(COMMENTS_NEW = str_detect(COMMENTS,"[^[:alnum:]///' ]", "")) %>% show_query()
Run Code Online (Sandbox Code Playgroud)
Error: str_detect() is not available in this SQL variant
Run Code Online (Sandbox Code Playgroud)
我已经重新安装了所有软件包,但仍然没有用。但是,我可以看到它是在dbplyr 1.2.0see here中实现的?
尝试与grepl它转化为:
db_tbl %>% mutate(COMMENTS_NEW = grepl(COMMENTS,pattern = '[^[:alnum:]]')) %>% show_query()
Run Code Online (Sandbox Code Playgroud)
db_tbl %>% mutate(COMMENTS_NEW = grepl(COMMENTS,pattern = '[^[:alnum:]]')) %>% show_query()
Run Code Online (Sandbox Code Playgroud)
也返回错误。这是回溯:
<SQL>
Named arguments ignored for SQL greplSELECT grepl("COMMENTS", '[^[:alnum:]]' AS "pattern") AS "COMMENTS_NEW"
FROM ("schema".table)
Run Code Online (Sandbox Code Playgroud)
继承人我的会议:
20.
stop(structure(list(message = "<SQL> 'SELECT * …Run Code Online (Sandbox Code Playgroud) 下载的数据来自MET办公室关于苏格兰的降雨量.
前几行:
Scotland Rainfall (mm)
Areal series, starting from 1910
Allowances have been made for topographic, coastal and urban effects where relationships are found to exist.
Seasons: Winter=Dec-Feb, Spring=Mar-May, Summer=June-Aug, Autumn=Sept-Nov. (Winter: Year refers to Jan/Feb).
Values are ranked and displayed to 1 dp. Where values are equal, rankings are based in order of year descending.
Data are provisional from February 2015 & Winter 2015. Last updated 26/11/2015
JAN Year FEB Year MAR Year APR Year MAY Year JUN Year …Run Code Online (Sandbox Code Playgroud) 我想创建ggplots为numeric cols反对我response variable。
这是可重现的代码:
test = mpg %>% select_if(is.numeric) %>%
dplyr::select(-year) %>% nest(-cyl) %>%
mutate(ggplots = map(data,~ggplot(data = .x) + geom_point(aes(x = cyl, y = .x))))
test
# A tibble: 4 x 3
cyl data ggplots
<int> <list<df[,3]>> <list>
1 4 [81 x 3] <gg>
2 6 [79 x 3] <gg>
3 8 [70 x 3] <gg>
4 5 [4 x 3] <gg>
Warning message:
All elements of `...` must be named.
Did you …Run Code Online (Sandbox Code Playgroud) 我正在尝试从位于以下网址的XML中读取:https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Frestaurants.xml
我在R中收到以下错误:
Error: XML content does not seem to be XML: 'https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Frestaurants.xml'
Run Code Online (Sandbox Code Playgroud)
我的代码:
install.packages("XML")
library(XML)
fileURL = "https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Frestaurants.xml"
doc = xmlTreeParse(fileURL)
Run Code Online (Sandbox Code Playgroud)
我想阅读那个XML文件并找出有多少家餐馆有邮政编码21231?
谢谢
您可以将summary方法的输出(如下所示)传输/复制到 Excel 表吗?
> summary(p2p_dt_SKILL_A[p2p_dt_SKILL_A$Patch %in% c("BVG1")])
Patch Skill Date TOR_MWF TOR_MA TOR_DL TOR_A TT_PR_TSK_A TT_PR_TSK_DL
BVG1 :100 A :100 Min. :2014-01-17 Min. :4.050 Min. :3.740 Min. :3.720 Min. :3.830 Min. : 98.49 Min. :104.8
BVG11: 0 BROADBAND : 0 1st Qu.:2014-07-09 1st Qu.:4.718 1st Qu.:4.550 1st Qu.:3.958 1st Qu.:4.100 1st Qu.:105.07 1st Qu.:109.9
BVG12: 0 CAL : 0 Median :2014-12-29 Median :5.205 Median :4.860 Median :4.040 Median :4.165 Median :109.48 Median :112.9
BVG13: 0 CIDT : 0 …Run Code Online (Sandbox Code Playgroud) 我希望传递params和headers到aiohttp.ClientSession如图所示这里。
这是我尝试过的:
async def make_request(self, url, headers, params):
async with aiohttp.ClientSession(headers=headers, params=params) as session:
async with self.limit, session.get(url=url) as response:
await asyncio.sleep(self.rate)
resp = await response.read()
return resp
Run Code Online (Sandbox Code Playgroud)
async def process(url, url_id, update_id, rate, limit):
limit = asyncio.BoundedSemaphore(limit)
f = Fetch(
rate=rate,
limit=limit,
)
if "coinmarketcap" in url:
params = {
'start': '1',
'limit': '1',
'convert': 'USD,BTC'
}
headers = {
'Accepts': 'application/json',
'X-CMC_PRO_API_KEY': API_KEY,
}
else:
params = {}
headers = …Run Code Online (Sandbox Code Playgroud) 我有一个叫当地的git repo CoachingManager.这有以下3个branches:
master
new_model
auto_setup_account
Run Code Online (Sandbox Code Playgroud)
如何创建一个CoachingManager使用完全相同的分支调用的github repo ?这应该可以立即跟踪.
对不起github的新手,所以只是想了解是否有一种快速简便的方法.
第一次尝试asyncio并且aiohttp。我有以下urls从MySQL数据库获取GET请求的代码。获取响应并将其推送到MySQL数据库。
if __name__ == "__main__":
database_name = 'db_name'
company_name = 'company_name'
my_db = Db(database=database_name) # wrapper class for mysql.connector
urls_dict = my_db.get_rest_api_urls_for_specific_company(company_name=company_name)
update_id = my_db.get_updateid()
my_db.get_connection(dictionary=True)
for url in urls_dict:
url_id = url['id']
url = url['url']
table_name = my_db.make_sql_table_name_by_url(url)
insert_query = my_db.get_sql_for_insert(table_name)
r = requests.get(url=url).json() # make the request
args = [json.dumps(r), update_id, url_id]
my_db.db_execute_one(insert_query, args, close_conn=False)
my_db.close_conn()
Run Code Online (Sandbox Code Playgroud)
这工作正常,但要加快速度我该如何运行它asynchronously?