我有两个列表,我想以元素方式连接它们.其中一个列表在连接之前经过字符串格式化.
例如 :
a = [0, 1, 5, 6, 10, 11]
b = ['asp1', 'asp1', 'asp1', 'asp1', 'asp2', 'asp2']
Run Code Online (Sandbox Code Playgroud)
在这种情况下,a
将进行字符串格式化.也就是说,新的a
或aa
应该是:
aa = [00, 01, 05, 06, 10, 11]
Run Code Online (Sandbox Code Playgroud)
最终输出应该是:
c = ['asp100', 'asp101', 'asp105', 'asp106', 'asp210', 'asp211']
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我该怎么做?
我正在运行Windows 10,VirtualBox 5和Vagrant 1.7.4并尝试运行openx平台.
我跑完后vagrant up
得到:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set network interfaces...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["hostonlyif", "ipconfig", "VirtualBox Host-Only Ethernet Adapter #25", "--ip", "192.168.33.1", "--netmask", "255.255.255.0"]
Stderr: VBoxManage.exe: error: The host network interface with the given name could not be found
VBoxManage.exe: error: Details: code E_INVALIDARG (0x80070057), component HostWrap, …
Run Code Online (Sandbox Code Playgroud) 我正在使用Eclipse Neon,我是从Eclipse Installer安装的.问题是当我想使用Swing时,我没有找到它.
当我尝试使用此解决方案安装时,我没有在霓虹灯存储库中找到它.有人可以帮忙吗?
我想知道Python是否具有sample()
R中的函数的等价物.
所述样品()函数将指定大小的使用具有或不具有替换x的元素的样品.
语法是:
sample(x, size, replace = FALSE, prob = NULL)
Run Code Online (Sandbox Code Playgroud)
(更多信息在这里)
任何人都可以向我解释每种用户类型(荣誉,验证,审计和员工)与他们的角色之间的区别吗?(每个用户的简要说明以及他们可以做什么).
我在官方文档中搜索过,但我一无所获!
谢谢.
我有两个数据框:
第一个 :
c1.df1 <- c(10, 55, 3)
c2.df1 <- c(-5, 18, 60)
df1 <- data.frame(c1.df1, c2.df1)
rownames(df1) <- c("row1", "row2", "row3")
colnames(df1) <- c("col1", "col2")
Run Code Online (Sandbox Code Playgroud)
结果 :
col1 col2
row1 10 -5
row2 55 18
row3 3 60
Run Code Online (Sandbox Code Playgroud)
第二个:
c1.df2 <- c(12, -99, 98)
c2.df2 <- c(-55, 8, 45)
df2 <- data.frame(c1.df2, c2.df2)
rownames(df2) <- c("row1", "row2", "row3")
colnames(df2) <- c("col1", "col2")
Run Code Online (Sandbox Code Playgroud)
结果 :
col1 col2
row1 12 -55
row2 -99 8
row3 98 45
Run Code Online (Sandbox Code Playgroud)
我想将它们两个放入一个数组中,并得到结果:
, , 1 …
Run Code Online (Sandbox Code Playgroud) 我有一个矩阵m
:
m <- matrix(c(1, 8, 3, 1, 2, 4, 9, 0, 0), nrow = 3, byrow = TRUE)
m
[,1] [,2] [,3]
[1,] 1 8 3
[2,] 1 2 4
[3,] 9 0 0
Run Code Online (Sandbox Code Playgroud)
我计算rowMeans(m)
:
r.mean <- rowMeans(m)
r.mean
[1] 4.000000 2.333333 3.000000
Run Code Online (Sandbox Code Playgroud)
我如何使用 从最大平均值到最小值对r.mean
矩阵进行排序:m
[,1] [,2] [,3]
[1,] 1 8 3
[2,] 9 0 0
[3,] 1 2 4
Run Code Online (Sandbox Code Playgroud) 我有这个数组:
arr = np.array([[[ -1., -1., -1., 0., 0., 0.],
[ 0.1, 0.1, 0.1, 2., 3., 4.]], # <-- this one
[[ -1., -1., -1., 0., 0., -1.],
[ 0.1, 0.1, 0.1, 16., 17., 0.1]], # <-- and this one
[[ -1., -1., -1., 0., 0., 0.],
[ 0.1, 0.1, 0.1, 4., 5., 6.]], # <-- and this one
[[ 0., 0., 0., -1., 0., 0.],
[ 1., 2., 3., 0.1, 1., 2.]], # <-- and this one
[[ -1., …
Run Code Online (Sandbox Code Playgroud) 我有一个包含以下内容的向量:
my.var <- c("a","b","c","d","e","f")
my.var
[1] "a" "b" "c" "d" "e" "f"
Run Code Online (Sandbox Code Playgroud)
我想只使用rep
和seq
函数来解决这个问题:
"a" "b" "c" "b" "c" "d" "c" "d" "e" "d" "e" "f"
Run Code Online (Sandbox Code Playgroud) 我有一个矩阵m
:
(m <- matrix(c(26,14,24,14,20,42,24,42,90), 3))
# [,1] [,2] [,3]
# [1,] 26 14 24
# [2,] 14 20 42
# [3,] 24 42 90
Run Code Online (Sandbox Code Playgroud)
当我运行solve(m)
计算矩阵的逆时,我收到此错误消息:
solve(m)
Run Code Online (Sandbox Code Playgroud)
solve.default(m)出错:系统计算奇异:倒数条件数= 6.21104e-18
我正在关注Rqc 包文档,所以我输入了以下内容:
library(Rqc)
folder <- system.file(package = "ShortRead", "extdata/E-MTAB-1147")
rqc(path = folder, pattern = ".fastq.gz")
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误:
位图错误(文件 = 文件名,宽度 = 宽度,高度 = 高度,res = 300):找不到 GhostScript
我想检查一个列表的范围是否在下一个列表的范围内,这是一个例子:
pos = [[50, 100], [50, 200], [250, 1500], [300, 2000], [300, 3300]]
Run Code Online (Sandbox Code Playgroud)
正如我们在这里看到的那样,在(包括在)pos[0]
的范围内,与with 和with 相同.pos[1]
[50, 100]
[50, 200]
pos[2]
pos[3]
pos[4]
pos[5]
为此,我创建了一个返回布尔值的函数:
def in_list(i): # index of the list
if i < len(pos)-2 and pos[i][0] >= pos[i+1][0] and pos[i][0] <= pos[i+1][1]
and pos[i][1] >= pos[i+1][0] and pos[i][1] <= pos[i+1][1]:
return True
else:
return False
Run Code Online (Sandbox Code Playgroud)
它看起来很难看,任何人都可以提出另一个解决方案吗?
编辑:
正如@MKesper建议的那样,我还应该使用循环遍历列表条目(并且可能获得每个位置的True/False列表).
我有一个清单:
lst = ['abcdef', 'uvwxyz']
Run Code Online (Sandbox Code Playgroud)
我想得到结果:
['fedcba', 'zyxwvu']
Run Code Online (Sandbox Code Playgroud)
我怎么能在Python 3中做到这一点(如果可能的话,还有Python 2)?
编辑:
在这里,我想颠倒列表中每个元素的内容!
不要反转列表中的元素!
如果我做:
lst[::-1]
Run Code Online (Sandbox Code Playgroud)
我去拿:
['uvwxyz', 'abcdef']
Run Code Online (Sandbox Code Playgroud)
那不是我想要的!
r ×6
python ×5
list ×2
matrix ×2
openedx ×2
arrays ×1
dataframe ×1
eclipse ×1
ghostscript ×1
java ×1
numpy ×1
probability ×1
python-2.7 ×1
python-3.x ×1
rep ×1
reverse ×1
seq ×1
vagrant ×1
vector ×1
virtualbox ×1