Remove 1st Column Pandas Code Example

Snippet 1

  df.drop('col_name',1) #1 drop column / 0 drop row 

Snippet 2

  To delete rows and columns from DataFrames, Pandas uses the “drop” function. To delete a column, or multiple columns, use the name of the column(s), and specify the “axis” as 1. 

Snippet 3

  df = df.drop(df.columns[[0, 1, 3]], axis=1)  # df.columns is zero-based pd.Index  

Copyright © Code Fetcher 2020



Leave a comment

Your email address will not be published. Required fields are marked *