How do I expand the output display to see more columns of a pandas DataFrame?

后端 未结 19 1917
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 00:37

Is there a way to widen the display of output in either interactive or script-execution mode?

Specifically, I am using the describe() function on a pand

19条回答
  •  一个人的身影
    2020-11-22 01:12

    None of these answers were working for me. A couple of them would indeed print all the columns, but it would look sloppy. As in all the information was there, but it wasn't formatted correctly. I'm using a terminal inside of Neovim so I suspect that to be the reason.

    This mini function does exactly what I need, just change df_data in the two places it is for your dataframe name (col_range is set to what pandas naturally shows, for me it is 5 but it could be bigger or smaller for you).

    import math
    col_range = 5
    for _ in range(int(math.ceil(len(df_data.columns)/col_range))):
        idx1 = _*col_range
        idx2 = idx1+col_range
        print(df_data.iloc[:, idx1:idx2].describe())
    

提交回复
热议问题