我又回到了一个新问题:AWS EBS Multi-Attach 卷上的文件系统必须是什么?
在本网站https://aws.amazon.com/premiumsupport/knowledge-center/ebs-access-volumes-using-multi-attach/
据记载,XFS、EXT3、EXT4 和 NTFS 等标准文件系统并非设计为由多个服务器或 EC2 实例同时访问。
但是,他们没有为 AWS EBS Multi-Attach 卷编写必须是什么文件系统。
任何的想法?如果您能提供用于设置文件系统的命令行,我会很高兴。
import pandas as pd
import numpy as np
dict1 = {'col1': ['A', 'A', 'A', 'A', 'A','B', 'B', 'B', 'B', 'B' ],
'col2':[2, 2, 2, 3, 3, 2, 2, 3, 3 , 3],
'col3':[0.7, 0.8, 0.9, 0.95, 0.85, 0.65, 0.75, 0.45, 0.55, 0.75 ],
'col4':[100,200,300,400,500,600,700,800,900,1000]}
df1 = pd.DataFrame(data=dict1)
df1
dict2 = {'col1': ['A', 'B' ],
'col2':[0.75, 0.65],
'col3':[1000, 2000 ],
'col4':[0.8, 0.9]}
df2 = pd.DataFrame(data=dict2)
df2
Run Code Online (Sandbox Code Playgroud)
以最快的方式如何使用 df2 过滤 df1,取决于 df1['col3'] >= df2['col2'] 对于相等的 col1s?
预期结果
>>> df1
col1 col2 …
Run Code Online (Sandbox Code Playgroud) 假设我们有以下 Pandas 系列是由在 groupby 之后应用于数据帧的应用函数产生的。
<class 'pandas.core.series.Series'>
0 (1, 0, [0.2, 0.2, 0.2], [0.2, 0.2, 0.2])
1 (2, 1000, [0.6, 0.7, 0.5], [0.1, 0.3, 0.1])
2 (1, 0, [0.4, 0.4, 0.4], [0.4, 0.4, 0.4])
3 (1, 0, [0.5, 0.5, 0.5], [0.5, 0.5, 0.5])
4 (3, 14000, [0.8, 0.8, 0.8], [0.6, 0.6, 0.6])
dtype: object
Run Code Online (Sandbox Code Playgroud)
当给出 sigList=['sig1','sig2', 'sig3'] 时,我们可以将其转换为数据帧吗?
Length Distance sig1Max sig2Max sig3Max sig1Min sig2Min sig3Min
1 0 0.2 0.2 0.2 0.2 0.2 0.2
2 1000 0.6 0.7 0.5 0.1 …
Run Code Online (Sandbox Code Playgroud) import pandas as pd
df = {'a': ['xxx', 'xxx','xxx','yyy','yyy','yyy'], 'start': [10000, 10500, 11000, 12000, 13000, 14000] }
df = pd.DataFrame(data=df)
df_new = df.groupby("a",as_index=True).agg(
ProcessiveGroupLength=pd.NamedAgg(column='start', aggfunc="count"),
StartMin=pd.NamedAgg(column='start', aggfunc="min"),
StartMax=pd.NamedAgg(column='start', aggfunc="max"),
)
Run Code Online (Sandbox Code Playgroud)
给
>>>df_new
ProcessiveGroupLength StartMin StartMax
a
xxx 3 10000 11000
yyy 3 12000 14000
Run Code Online (Sandbox Code Playgroud)
如何快速到达下方,因为我认为它会更快。
>>>df_new
ProcessiveGroupLength Diff
a
xxx 3 1000
yyy 3 2000
Run Code Online (Sandbox Code Playgroud)
下面的代码给出了以下错误消息:
回溯(最近一次调用):文件“”,第 5 行,类型错误:不支持的操作数类型 -:'str' 和 'str'
df_new = df.groupby("a").agg(
ProcessiveGroupLength=pd.NamedAgg(column='start', aggfunc="count"),
Diff=pd.NamedAgg(column='start', aggfunc="max"-"min"),)
Run Code Online (Sandbox Code Playgroud) import pandas as pd
import numpy as np
df = {'a': ['aa', 'aa', 'aa', 'aaa', 'aaa'],
'b':['bb', 'bb', 'bb', 'bbb', 'bbb'],
'c':[10,20,30,100,200]}
df = pd.DataFrame(data=df)
my_dict=df.groupby(['a', 'b'])['c'].apply(np.hstack).to_dict()
Run Code Online (Sandbox Code Playgroud)
给出以下字典
>>> my_dict
{('aa', 'bb'): array([10, 20, 30]), ('aaa', 'bbb'): array([100, 200])}
Run Code Online (Sandbox Code Playgroud)
除了使用之外,还有更快/更有效的方法apply
吗?
可能有以前的问题,但当您搜索它们时它们不会出现。这个问题及其标题内容非常丰富。
import pandas as pd
df1 = pd.DataFrame({'lkey': ['foo', 'bar', 'baz'], 'x1': [1, 2, 3], 'x2': [11, 22, 33]})
df2 = pd.DataFrame({'rkey': ['foo', 'bar', 'bazz'], 'y1': [1, 2, 3], 'y2': [111, 222, 333]})
merged_df = pd.merge(df1, df2, how= 'inner', left_on=['lkey','x1'], right_on=['rkey','y1'])
merged_df
Run Code Online (Sandbox Code Playgroud)
如何显示 df1 的哪些行未合并?
列出 df1 中未合并的行以及列“ lkey ”和“ x1 ”将会非常有帮助。
baz 3
Run Code Online (Sandbox Code Playgroud) 假设我们有以下 Pandas 数据框:
df = pd.DataFrame({'col1':['A>G','C>T','C>T','G>T','C>T', 'A>G','A>G','A>G'],'col2':['TCT','ACA','TCA','TCA','GCT', 'ACT','CTG','ATG'], 'start':[1000,2000,3000,4000,5000,6000,10000,20000]})
input:
col1 col2 start
0 A>G TCT 1000
1 C>T ACA 2000
2 C>T TCA 3000
3 G>T TCA 4000
4 C>T GCT 5000
5 A>G ACT 6000
6 A>G CTG 10000
7 A>G ATG 20000
8 C>A TCT 10000
9 C>T ACA 2000
10 C>T TCA 3000
11 C>T TCA 4000
Run Code Online (Sandbox Code Playgroud)
我想得到的是 col1 中连续值的数量和这些连续值的长度以及最后一个元素的开始和第一个元素的开始之间的差异:
output:
type length diff
0 C>T 2 1000
1 A>G 3 14000
2 C>T 3 2000
Run Code Online (Sandbox Code Playgroud)