Pandas DataFrame.to_string () truncate rows from columns

When I try to use to_string to output a column from a dataframe , it truncates the output of the column.

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

Any ideas on how to solve this problem? Thank you

+7
source share
1 answer

The use of __repr__ or to_string columns is reduced by 50 characters by default. In versions of Pandas older than 0.13.1, this can be controlled using pandas.set_printoptions() :

 In [64]: df Out[64]: AB 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]: AB a this is a very long string, longer than the default max_column width bar b foo baz 

In later versions of Pandas use instead:

 pd.options.display.max_colwidth = 100 
+10
source

All Articles