我有一个数据文件df
oligo_name oligo_sequence
AAAAA attttggggctggtaa
BBBBB attttcccgaatgtca诸若此类。为了计算每个序列的GC含量,我执行了以下操作
from Bio.SeqUtils import GC
df['GC content'] = GC(df['oligo_sequence'])但我得到了以下错误:
KeyError: 'Level G must be same as name (None)'你能建议一个修正或更好的方法来计算熊猫数据框架中的GC含量吗?谢谢
发布于 2015-04-27 18:47:35
以下几点对我有用:
In [23]:
df['GC content'] = df['oligo_sequence'].apply(GC)
df
Out[23]:
oligo_name oligo_sequence GC content
0 AAAAA attttggggctggtaa 43.75
1 BBBBB attttcccgaatgtca 37.50您不能将Series作为param传递给函数,除非它了解熊猫系列或数组类型是什么,因此您可以调用apply并将该函数作为param传递,该函数将对该系列中的每个值调用该函数,如上面所示。
https://stackoverflow.com/questions/29902938
复制相似问题