作为新R,可有人请解释之间的区别paste()和paste0(),就是我的理解,从一些后是
paste0("a", "b") === paste("a", "b", sep="")
Run Code Online (Sandbox Code Playgroud)
即使我尝试过这样的事情
a <- c("a","b","c")
b <- c("y","w","q")
paste(a,b,sep = "_")
**output**
"a_y" "b_w" "c_q"
Run Code Online (Sandbox Code Playgroud)
paste0()a <- c("a","b","c")
b <- c("y","w","q")
paste0(a,b,sep = "_")
**output**
"ay_" "bw_" "cq_"
Run Code Online (Sandbox Code Playgroud)
它只是paste()在元素之间paste0()使用分隔符并在元素之后使用分隔符吗?
这是我的数据帧df
a b c
1.2 2 0.1
2.1 1.1 3.2
0.2 1.9 8.8
3.3 7.8 0.12
Run Code Online (Sandbox Code Playgroud)
我试图从数据帧的每一行获得最大值,我期待这样的输出
max_value
2
3.2
8.8
7.8
Run Code Online (Sandbox Code Playgroud)
这就是我尝试过的
df[len(df.columns)].argmax()
Run Code Online (Sandbox Code Playgroud)
我没有得到正确的输出,任何帮助将非常感激.谢谢
我正在进行反向地理编码并更新生成的 O/P(JSON 格式)并使用 json O/P 更新 sql 表列,但它无法按预期正确存储或更新它。
这是进行反向地理编码后更新的内容
>pw
{'results': [{'address_components': [{'long_name': 'Nandanvan A Wing', 'short_name': 'Nandanvan A Wing', 'types': ['establishment', 'point_of_interest', 'premise']}, {'long_name': 'Shivaji Nagar Marg', 'short_name': 'Shivaji Nagar Marg', 'types': ['route']}, {'long_name': 'Vishnu Prasad Society', 'short_name': 'Vishnu Prasad Society', 'types': ['neighborhood', 'political']}, {'long_name': 'Navpada', 'short_name': 'Navpada', 'types': ['political', 'sublocality', 'sublocality_level_3']}, {'long_name': 'Parle Colony', 'short_name': 'Parle Colony', 'types': ['political', 'sublocality', 'sublocality_level_2']}, {'long_name': 'Vile ....72.8454698}}}, 'place_id': 'ChIJ1SbMGMrJ5zsRQd3_uFHHDN4', 'types': ['political', 'sublocality', 'sublocality_level_3']}], 'status': 'OK'}
但这就是事实,
这是我使用的代码
import pyodbc …Run Code Online (Sandbox Code Playgroud) 我正在计算员工的出勤率,这是示例表
df = pd.DataFrame({
'E_ID': [1001, 1001, 1001, 1002, 1002, 1002, 1002],
'Date': [
'28-07-2019 08:27:00',
'28-07-2019 18:10:00',
'29-07-2019 08:10:00',
'28-07-2019 08:07:00',
'29-07-2019 08:10:10',
'29-07-2019 08:10:17',
'29-07-2019 17:50:00'
]
})
Run Code Online (Sandbox Code Playgroud)
我正在尝试从的Date列中计算每天的In-Time和Out-Time df。
此外,每天可能会有一次输入,可以视为“按时上班”。
In-Time将是第一个打入 ,而 Out-Time将是最后一个打入。
我期望输出这样的东西,或者可能是类似的东西
E_ID OfficePunch In Punch Out Punch
1001 28-08-2019 28-07-2019 08:27 28-07-2019 18:10
1001 29-08-2019 29-07-2019 08:10 29-07-2019 08:10
1002 28-08-2019 28-07-2019 08:07 28-07-2019 08:07
1002 29-08-2019 29-07-2019 08:10 29-07-2019 17:50
Run Code Online (Sandbox Code Playgroud)
有什么办法可以做到?
这是一个代码片段,我正在尝试使用!:
demo <- <dataframe>[!which(<dataframe>$<col_name> == 0),]
Run Code Online (Sandbox Code Playgroud)
但它没有给我正确的输出。
当我使用-在:
demo <- <dataframe>[-which(<dataframe>$<col_name>== 0),]
Run Code Online (Sandbox Code Playgroud)
它给我带来了正确的答案。
有人可以解释为什么会这样吗?
例如我有
a=c("Jack and Jill,went up the, hill,to,fetch a pail,of, water")
Run Code Online (Sandbox Code Playgroud)
我试图做的是在逗号后添加空格,当且仅当逗号后跟一个字母表,这样我的输出看起来像这样
"Jack and Jill, went up the, hill, to, fetch a pail, of, water"
Run Code Online (Sandbox Code Playgroud)
这是我尝试过的
gsub("/,(?![ ])/, ", " ",a)
Run Code Online (Sandbox Code Playgroud)
但没有给我想要的结果。任何帮助将非常感激。谢谢
我正在尝试在三个字符向量中使用多个元素的组合,但我只获得最后一个元素迭代,我还想在创建组合列表时设置我的budg_min不应大于budg_max的条件
这是我的代码
text1="http://www.magicbricks.com/property-for-sale/residential-real-estate?bedroom="
text3="&proptype="
text4="Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment"
text5="&cityName=Thane&BudgetMin="
text6="&BudgetMax="
uuu=list()
bhk=c("1","2","3","4","5",">5")
budg_min=c("5-Lacs","10-Lacs","20-Lacs","30-Lacs","40-Lacs","50-Lacs","60-Lacs","70-Lacs","80-Lacs","90-Lacs","1-Crores","1.2-Crores","1.4-Crores","1.6-Crores","1.8-Crores","2-Crores","2.3-Crores","2.6-Crores","3-Crores","3.5-Crores","4-Crores","4.5-Crores","5-Crores","10-Crores","20-Crores")
budg_max=c("5-Lacs","10-Lacs","20-Lacs","30-Lacs","40-Lacs","50-Lacs","60-Lacs","70-Lacs","80-Lacs","90-Lacs","1-Crores","1.2-Crores","1.4-Crores","1.6-Crores","1.8-Crores","2-Crores","2.3-Crores","2.6-Crores","3-Crores","3.5-Crores","4-Crores","4.5-Crores","5-Crores","10-Crores","20-Crores")
for(i in bhk){
for(j in budg_min){
for(k in budg_max) {
if(budg_min>budg_max){"Skip that combination "}
else{
uuu[i]=paste(text1,i,text3,text4,text5,j,text6,k,sep = "")
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我期待输出像
[1]
http://www.magicbricks.com/property-for-sale/residential-real-estate?bedroom=1&proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment&cityName=Thane&BudgetMax=5-Lacs
[2]
http://www.magicbricks.com/property-for-sale/residential-real-estate?bedroom=1&proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment&cityName=Thane&BudgetMin=5-Lacs&BudgetMax=10-Lacs
[3]
http://www.magicbricks.com/property-for-sale/residential-real-estate?bedroom=1&proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment&cityName=Thane&BudgetMin=5-Lacs&BudgetMax=20-Lacs
.
.
.
.
[n]
http://www.magicbricks.com/property-for-sale/residential-real-estate?bedroom=%3E5&proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment&cityName=Thane&BudgetMax=20-Crores
Run Code Online (Sandbox Code Playgroud)
注意:在上面的输出中,list的第一个元素只包含BudgetMax 参数,list的last(nth)元素只有BudgetMax参数,rest元素是bhk,budg_min和budg_min的组合.
但是我的代码只提供了6条记录
[1] "http://www.magicbricks.com/property-for-sale/residential-real-estate?bedroom=1&proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment&cityName=Thane&BudgetMin=20-Crores&BudgetMax=20-Crores"
$`2`
[1] "http://www.magicbricks.com/property-for-sale/residential-real-estate?bedroom=2&proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment&cityName=Thane&BudgetMin=20-Crores&BudgetMax=20-Crores"
$`3`
[1] "http://www.magicbricks.com/property-for-sale/residential-real-estate?bedroom=3&proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment&cityName=Thane&BudgetMin=20-Crores&BudgetMax=20-Crores"
$`4`
[1] "http://www.magicbricks.com/property-for-sale/residential-real-estate?bedroom=4&proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment&cityName=Thane&BudgetMin=20-Crores&BudgetMax=20-Crores"
$`5`
[1] "http://www.magicbricks.com/property-for-sale/residential-real-estate?bedroom=5&proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment&cityName=Thane&BudgetMin=20-Crores&BudgetMax=20-Crores"
$`>5`
[1] "http://www.magicbricks.com/property-for-sale/residential-real-estate?bedroom=>5&proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment&cityName=Thane&BudgetMin=20-Crores&BudgetMax=20-Crores"
Run Code Online (Sandbox Code Playgroud)
应该对我的代码进行哪些更改,以便它提供我的所有组合.任何帮助将不胜感激.谢谢
我想提取我尝试过的所有<li>元素文本<ul>
elem = driver.find_elements_by_xpath(("//div[@class='left width50']/p/b/ul"))
len(elem)
Run Code Online (Sandbox Code Playgroud)
给出 '0' 或空列表。
这是 html 源代码
<div class="left width50">
<p><b>Features:</b></p>
<ul>
<li>Easy spray application</li>
<li>Excellent bonding properties</li>
<li>Single package</li>
<li>Mixed with clean potable water at job site</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
这里是网站的链接
有什么建议怎么办?