I have a df and I want to drop a column by label but in a case insensitive way. Note: I don't want to change anything in my df so I'd like to avoid 'str.lower'.
heres my df:
print df
Name UnweightedBase Base q6a1 q6a2 q6a3 q6a4 q6a5 q6a6 eSubTotal
Name
Base 1006 1006 100,00% 96,81% 96,81% 96,81% 96,81% 3,19% 490,44%
q6_6 31 32 100,00% - - - - - -
q6_3 1006 1006 43,44% 26,08% 13,73% 9,22% 4,34% 3,19% 100,00%
q6_4 1006 1006 31,78% 31,71% 20,09% 10,37% 2,87% 3,19% 100,00%
Is there any magic I can apply to the code below?
df.drop(['unWeightedbase', 'Q6A1'],1)
I think what you can do is create a function to perform the case-insensitive search for you:
my search code is attributed to this SO one: find the index of a string ignoring cases