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
To find duplicate columns we need to iterate through all columns of a DataFrame and for each and every column it will search if any other column exists in DataFrame with the same contents already. If yes then that column name will be stored in the duplicate column set.
To drop duplicate columns from pandas DataFrame use df. T. drop_duplicates(). T , this removes all columns that have the same data regardless of column names.
loc[] is used to select rows and columns by Names/Labels. iloc[] is used to select rows and columns by Integer Index/Position. zero based index position.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With