Home python Delete Pandas column

Delete Pandas column

Author

Date

Category

It is impossible to remove the Pandas column either using DEL or with Drop, what am I doing wrong?

df = pd.read_excel (s_path, header = none)
    DF = DF.DROP (0, 1)
    # Del DF [0]
    # df.drop (df.columns [[0]], axis = 1, inplace = True)
    DF.TO_EXCEL (S_PATH)

tried listed options (including commented)
On the fact, only the sputter with the indexes

is added


Answer 1, Authority 100%

import pandas as pd
df = pd.dataframe ({"a": [1,2,3,4], "b": [11,12,13,14]})
Print (DF)
a b
0 1 11.
1 2 12.
2 3 13.
3 4 14.
df.drop ("b", axis = 1, inplace = true)
Print (DF)
a
0 1.
12
2 3.
3 4.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions