【发布时间】:2012-08-16 20:11:51
【问题描述】:
当我尝试使用 to_string 从dataframe 输出一列时,它会截断该列的输出。
print gtf_df.ix[:1][['transcript_id','attributes']].to_string(header=False,index=False)
Out: ' CUFF.1.1 gene_id "CUFF.1"; transcript_id "CUFF.1.1"; FPKM '
print gtf_df.ix[:1]['attributes'][0]
Out: 'gene_id "CUFF.1"; transcript_id "CUFF.1.1"; FPKM "1670303.8168650887"; frac "1.000000"; conf_lo "0.000000"; conf_hi "5010911.450595"; cov "9658.694354";'
关于如何解决这个问题的任何想法? 谢谢!
【问题讨论】:
-
属性的类型是什么 -- 即你从 type(gtf_df['attributes'][0]) 得到什么 -- 如果是字符串,能否告诉我们是否删除引号和分号解决了问题——即 gtf_df.attributes = gtf_df.attributes.replace('\"','').replace(';','')
-
它是一个字符串列。但是,您推荐的修复并没有改变任何东西。下面给出的答案有效。