Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Business Analyst
  3. Question
Business Analyst

How to delete the last row of data of a pandas dataframe?

Asked by Bernadette Bond May 21, 2021 2.4K views 1 answer
Share

About this question

 I think this should be simple, but I tried a few ideas and none of them worked:

last_row = len(DF)
DF = DF.drop(DF.index[last_row])  #<-- fail!

I tried using negative indices but that also lead to errors. I must still be misunderstanding something basic. 

Please help how pandas drop last row? Thanks in advance.

Your answer

1 Answer

More Business Analyst discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Business Analyst Blogs

Guides, tips and career advice on Business Analyst from JanBask experts.