1

I have to load excel file with few column to pandas data frame. In That Excel file some times data use come with column names "Unnamed 1" ,"Unnamed 2", "Unnamed 3" . I want to delete all the columns where column names start with "Unnamed" . How to do this ? Suppose my data frame name is df .

2
  • 1
    do you save CSV files through pandas? Commented Oct 28, 2020 at 8:38
  • Yes will save to CSV . Before that I want to drop the columns with column name starting with "Unnamed" . Commented Oct 28, 2020 at 8:40

1 Answer 1

1

The easiest way to use this with regex is:

df.drop(list(df.filter(regex = 'Unnamed')), axis = 1, inplace = True)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.