35

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
  • 11,406
  • 26
  • 72
  • 114

1 Answers1

67

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
  • 71,268
  • 10
  • 134
  • 170