Answers for "how to drop first column in pandas"

0

remove first row of dataframe

df = df.iloc[1: , :]
Posted by: Guest on September-17-2021
1

remove 1st column pandas

df = df.drop(df.columns[[0, 1, 3]], axis=1)  # df.columns is zero-based pd.Index
Posted by: Guest on May-20-2020
4

how to delete a column from a dataframe in python

del df['column']
Posted by: Guest on April-11-2020
0

how to drop a column by name in pandas

>>> midx = pd.MultiIndex(levels=[['lama', 'cow', 'falcon'],
...                              ['speed', 'weight', 'length']],
...                      codes=[[0, 0, 0, 1, 1, 1, 2, 2, 2],
...                             [0, 1, 2, 0, 1, 2, 0, 1, 2]])
>>> df = pd.DataFrame(index=midx, columns=['big', 'small'],
...                   data=[[45, 30], [200, 100], [1.5, 1], [30, 20],
...                         [250, 150], [1.5, 0.8], [320, 250],
...                         [1, 0.8], [0.3, 0.2]])
>>> df
                big     small
lama    speed   45.0    30.0
        weight  200.0   100.0
        length  1.5     1.0
cow     speed   30.0    20.0
        weight  250.0   150.0
        length  1.5     0.8
falcon  speed   320.0   250.0
        weight  1.0     0.8
        length  0.3     0.2
Posted by: Guest on August-29-2020

Code answers related to "how to drop first column in pandas"

Python Answers by Framework

Browse Popular Code Answers by Language