Is there a pandas function to display the first/last n columns, as in .head() & .tail()?

后端 未结 5 948
花落未央
花落未央 2020-12-05 15:13

I love using the .head() and .tail() functions in pandas to circumstantially display a certain amount of rows (sometimes I want less, sometimes I w

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-05 15:49

    You could just use df.col.head(n) for what your are trying to do... see example below,

    df = pd.DataFrame({'a': [i for i in range(101)],
                       'b': [i for i in range(101)]})
    df.a.head(4)
    
    Out[37]:
    0    0
    1    1
    2    2
    3    3
    Name: a, dtype: int64
    

提交回复
热议问题