How to slice a Pandas Data Frame by position?

后端 未结 5 734
北荒
北荒 2020-11-30 05:47

I have a Pandas Data Frame object that has 1000 rows and 10 columns. I would simply like to slice the Data Frame and take the first 10 rows. How can I do this? I\'ve been tr

5条回答
  •  没有蜡笔的小新
    2020-11-30 06:07

    http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.head.html?highlight=head#pandas.DataFrame.head

    df2 = df.head(10)
    

    should do the trick

提交回复
热议问题