I want to extract some columns maybe just 10 from a datafram with 30 columns but I'm not finding any code or functions to do it, I tried with iloc but not good results at all, help please here is my data frame:
So I just want to get the columns 1 to 10: df1_10 = df.columns['1'....'10']
CodePudding user response:
If you want to fetch 10 columns from your dataset then use this piece of code
df.iloc[:,1:11] # this will give you 10 columns
df.iloc[:,1:10] # this will give you only 9 columns.
# This is what you use in your code that's why you don't get the desired result.