2016-08-11 3 views
4

팬더를 다룰 때, 운동 상태 및 각도 상태의 개체 분석을 인쇄하려고합니다. 데이터를 인쇄 할 물었을 때Python - 팬더 출력 제한 열

def displayData(tList, xList, zList, dxList, dzList, thetaList, dthetaList, Q_sList): 
    states = pd.DataFrame({ 't' : tList, 
          'x' : xList, 
          'z' : zList, 
          'dx' : dxList, 
          'dz' : dzList, 
          'theta' : thetaList, 
          'dtheta' : dthetaList, 
          'Q_s' : Q_sList}) 

    print states[['t', 'x', 'z', 'dx', 'dz', 'theta', 'dtheta', 'Q_s']] 

그러나, 출력이 특정 지점 이상으로 열을 나누기 : 다음과 같이 그렇게 내 코드는

  t   x   z   dx   dz  theta \ 
0  0.000 -500.000000 -100.000000 100.000000 -0.000000 0.000000 
1  0.005 -499.500000 -100.000000 99.999983 0.057692 -0.000577 
2  0.010 -499.000000 -99.999712 99.999933 0.115329 -0.001153 
...  ...   ...   ...   ...  ...  ... 

     dtheta  Q_s 
0 -0.115385 -0.038462 
1 -0.115274 -0.038425 
2 -0.115163 -0.038388 
...  ...  ... 

나는 국가의 많은 수천으로 그 당시 인쇄하려면 판다가 테이블을 깨지 말고 남은 두 개의 데이터 필드를 가져와 스크롤하지 않고 주어진 상태를 분석 할 수있게하고 싶습니다. 이 문제가 발생하지 않도록 인쇄 할 특정 치수를 정의 할 수있는 방법이 있습니까? pd.options.display.width하고 여기에

pd.options.display.expand_frame_repr 작은 데모입니다 :

+6

세트 :'pd.options.display.expand_frame_repr = False' – MaxU

+0

작동 완벽하게 –

+1

그 대답 안해 주실 래요? 이 질문은 외부 세계로부터 답변을 얻지 못한 것처럼 보입니다. 작은 대답이라는 사실은 중요하지 않습니다. 맞죠? – vmg

답변

1

이 경우에 사용할 수있는 두 가지 유용한 settings 있습니다 택일

In [118]: pd.options.display.expand_frame_repr 
Out[118]: True 

In [119]: pd.options.display.width = 50 

In [120]: df 
Out[120]: 
     t  x   z   dx \ 
0 0.000 -500.0 -100.000000 100.000000 
1 0.005 -499.5 -100.000000 99.999983 
2 0.010 -499.0 -99.999712 99.999933 

     dz  theta dtheta  Q_s 
0 -0.000000 0.000000 -0.115385 -0.038462 
1 0.057692 -0.000577 -0.115274 -0.038425 
2 0.115329 -0.001153 -0.115163 -0.038388 

In [121]: pd.options.display.width = 100 

In [122]: df 
Out[122]: 
     t  x   z   dx  dz  theta dtheta  Q_s 
0 0.000 -500.0 -100.000000 100.000000 -0.000000 0.000000 -0.115385 -0.038462 
1 0.005 -499.5 -100.000000 99.999983 0.057692 -0.000577 -0.115274 -0.038425 
2 0.010 -499.0 -99.999712 99.999933 0.115329 -0.001153 -0.115163 -0.038388 

In [131]: pd.options.display.width = 40 

In [132]: df 
Out[132]: 
     t  x   z \ 
0 0.000 -500.0 -100.000000 
1 0.005 -499.5 -100.000000 
2 0.010 -499.0 -99.999712 

      dx  dz  theta \ 
0 100.000000 -0.000000 0.000000 
1 99.999983 0.057692 -0.000577 
2 99.999933 0.115329 -0.001153 

    dtheta  Q_s 
0 -0.115385 -0.038462 
1 -0.115274 -0.038425 
2 -0.115163 -0.038388 


In [125]: pd.options.display.expand_frame_repr = False 

In [126]: df 
Out[126]: 
     t  x   z   dx  dz  theta dtheta  Q_s 
0 0.000 -500.0 -100.000000 100.000000 -0.000000 0.000000 -0.115385 -0.038462 
1 0.005 -499.5 -100.000000 99.999983 0.057692 -0.000577 -0.115274 -0.038425 
2 0.010 -499.0 -99.999712 99.999933 0.115329 -0.001153 -0.115163 -0.038388 

In [127]: pd.options.display.width 
Out[127]: 30 

, 당신은 set_options() 방법 다음은

을 사용할 수 있습니다 diplay 옵션 목록 :

In [128]: pd.options.display. 
pd.options.display.chop_threshold  pd.options.display.latex    pd.options.display.mpl_style 
pd.options.display.colheader_justify pd.options.display.line_width   pd.options.display.multi_sparse 
pd.options.display.column_space  pd.options.display.max_categories  pd.options.display.notebook_repr_html 
pd.options.display.date_dayfirst  pd.options.display.max_columns  pd.options.display.pprint_nest_depth 
pd.options.display.date_yearfirst  pd.options.display.max_colwidth  pd.options.display.precision 
pd.options.display.encoding   pd.options.display.max_info_columns pd.options.display.show_dimensions 
pd.options.display.expand_frame_repr pd.options.display.max_info_rows  pd.options.display.unicode 
pd.options.display.float_format  pd.options.display.max_rows   pd.options.display.width 
pd.options.display.height    pd.options.display.max_seq_items 
pd.options.display.large_repr   pd.options.display.memory_usage