46

I have a dataframe with about 500 columns and that's why I am wondering if there is anyway that I could use head() function but want to see the first 50 columns for example.

Thanks

ahajib
  • 12,838
  • 29
  • 79
  • 120

1 Answers1

86

I wasn't sure if you meant rows or columns.

If it's rows, then

df.head(50)

will do the trick.

If it's columns, then

df.iloc[:, : 50]

will work.

Of course, you can combine them.


You can see this stuff at Indexing and Selecting Data.

Ami Tavory
  • 74,578
  • 11
  • 141
  • 185