如果你有两对值,开始和结束 - 你如何计算它们的重叠位置?
即,如果开始和结束值对是
[10,20],[15,20]
在这种情况下compute_overlap((15,20),(10,20))应该返回,(15,20)因为这是重叠的地方.
做这个的最好方式是什么?
length (1,2)
Run Code Online (Sandbox Code Playgroud)
返回结果,但是
length (1, 2, 3)
Run Code Online (Sandbox Code Playgroud)
给出错误.这是为什么?
读类型的(,)和(,,)没有帮助.
编辑:我想的是长度 Data.Foldable length :: Foldable t => t a -> Int
我尝试阅读文档,但我仍然很困惑。pyarrow 表能够执行 groupbys 和所有精彩的 pandas 功能吗?
import pyarrow as pa
import pandas as pd
df = pd.DataFrame({"a": [1, 2, 3]})
table = pa.Table.from_pandas(df)
Run Code Online (Sandbox Code Playgroud)
但现在是虎头蛇尾:
table["a"]
# ---------------------------------------------------------------------------
# TypeError Traceback (most recent call last)
# <ipython-input-18-fb884245e2de> in <module>()
# ----> 1 table["a"]
# table.pxi in pyarrow.lib.Table.__getitem__()
# TypeError: an integer is required
table[0]
# <pyarrow.lib.Column object at 0x111306330>
# chunk 0: <pyarrow.lib.Int64Array object at 0x11728d1d8>
# [
# 1,
# 2,
# 3
# ]
c = table[0]
c[c>2]
# …Run Code Online (Sandbox Code Playgroud) 我想做一个类似的查询
select * from chr2;
Run Code Online (Sandbox Code Playgroud)
但只让 MySQL 返回第一个元组(或任意)元组而不是所有元组。
我该怎么做?
为什么下面的减号被视为无效令牌?这里肯定有一些我不理解的东西.
>>> [1e-i for i in range(-10,10)]
SyntaxError: invalid token
Run Code Online (Sandbox Code Playgroud)
通常情况下,这些东西像母亲一样评价:
>>> 1e-10
1e-10
Run Code Online (Sandbox Code Playgroud)
我只是好奇; 我解决了我的问题
>>> [10**i for i in range(-10,10)]
[1e-10, 1e-09, 1e-08, 1e-07, 1e-06, 1e-05, 0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]
Run Code Online (Sandbox Code Playgroud) 我想打印文件的所有标题行:
perl -wnl -e "/^#/ and print" file.vcf
Run Code Online (Sandbox Code Playgroud)
这有效 - 但是,我想在完成标题后退出.
怎么了?
perl -wnl -e "/^#/ and print else exit" file.vcf
Run Code Online (Sandbox Code Playgroud)
?
我有一些代码,我想用它来查找已排序文件中的重复项.(awk启发的)代码如下所示:
perl -wnla -e 'BEGIN {$previous = -1} $F[1] == $previous ? print $F[1] : $previous = $F[1]' ../VCF/FIN_20.vcf
Run Code Online (Sandbox Code Playgroud)
不幸的是它给了我一个错误:
Can't modify print in scalar assignment at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
Run Code Online (Sandbox Code Playgroud)
我需要做些什么才能让它发挥作用?
PS.该文件看起来像
20 5282284 rs73594467
20 5282299 rs148317959
20 5282336 rs927106
Run Code Online (Sandbox Code Playgroud) 我目前想要将数字从1到23作为字符串.
我到达的方法感觉有点难以阅读:
CHROMOSOME_NUMBERS = (1..23).to_a.map { |n| n.to_s }
Run Code Online (Sandbox Code Playgroud)
这样做有更漂亮的方法吗?
我想为我的测试编写描述性名称,这使得名称很长。
是否可以避免调用测试test_<something>而使用装饰器或其他东西?或者可以通过一些命令行参数来完成?
这是我用于创建自定义ZipList类的自定义List类.我想创建一个ZipList的应用实例.
import Control.Applicative
data List a =
Nil
| Cons a (List a)
deriving (Eq, Show)
instance Functor List where
fmap f (Cons x xs) = Cons (f x) (fmap f (Cons (head' xs) (tail' xs)))
fmap _ Nil = Nil
instance Applicative List where
pure x = Cons x Nil
(<*>) fs xs = Cons (head' fs $ head' xs) ((<*>) (tail' fs) (tail' xs))
head' :: List a -> a
head' (Cons a _) = a
tail' :: …Run Code Online (Sandbox Code Playgroud) python ×3
haskell ×2
perl ×2
algorithm ×1
applicative ×1
command-line ×1
mysql ×1
pandas ×1
pyarrow ×1
pytest ×1
python-2.7 ×1
ruby ×1
sql ×1