You can delete every second column in a pandas DataFrame using the following code snippet:
main.py201 chars8 lines
In this example, we create an example DataFrame with columns A, B, C, and D. The df.drop()
method is used to remove every second column of the DataFrame, starting from the first column (index 0). The resulting DataFrame df
will only contain columns B and D.
gistlibby LogSnag