12

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";'

この問題を解決する方法について何かアイデアはありますか?ありがとう!

4

2 に答える 2

12

__repr__または列の使用to_stringは、デフォルトで50文字で切り捨てられます。0.13.1より古いバージョンのPandasでは、これは次を使用して制御できますpandas.set_printoptions()

In [64]: df
Out[64]:
                                                   A    B
a  this is a very long string, longer than the defau  bar
b                                                foo  baz

In [65]: pandas.set_printoptions(max_colwidth=100)

In [66]: df
Out[66]:
                                                                      A    B
a  this is a very long string, longer than the default max_column width  bar
b                                                                   foo  baz

Pandasの最近のバージョンでは、代わりにこれを使用してください。

pd.options.display.max_colwidth = 100
于 2012-08-17T06:54:29.743 に答える
1

パンダはこのオプションの設定方法を変更しました。これが現在のドキュメントです

pd.set_option('display.max_colwidth', 100)

次のような他の優れたものについては、ドキュメントを参照してください。

pd.set_option('display.max_rows', 999)
于 2018-09-22T03:48:03.493 に答える