How to show first+last N rows of a DataFrame

  • Thread starter August W. Gruneisen
  • Start date

August W. Gruneisen

I am looking for the best way to quickly preview the first and last N rows of a DataFrame at the same time.

I realize I can use df.head(N) and df.tail(N) separately but this returns two DataFrames. Is it best to simply call these 2 separate functions and concatenate the two, or is there a simpler method for this?


df.head(5) # first 5 rows
df.tail(5) # last 5 rows


df.headtail(5) # 10 rows total

Would like to display the first and last 5 rows as a single DataFrame for quick preview of the 'range' of my dataset.

Continue reading...