Assuming that the columns in your dataframe (let's call it df
) are indexed starting at 0, you can use the modulo operator (%
) in combination with a list comprehension to remove all the odd columns like this:
main.py65 chars2 lines
This will create a new dataframe containing only the even columns of the original df
.
gistlibby LogSnag