How to delete rows from pandas dataframe?

To delete a row or n rows from a pandas dataframe you can use following command

DataFrame.drop(labels=None, axis=0, index=None, columns=None, level=None, inplace=False, errors='raise')

Let's assume you have a dataframe with 100 employees data with employee id's ranging from 1 to 100. If you want to drop all employees from dataframe with employee id between 5 and 10. Then you can use following command to do this.

df.drop(df.loc[((df.emp_id >= 5) & (df.emp_id <= 10))].index, inplace=True)

If you want to drop all employees with employee id greater than 90. Then you can modify above as following.

df.drop(df.loc[df.emp_id > 90].index, inplace=True)


For more such tips stay tuned.

Was this article helpful?

Top Related Jobs

Top Freelance jobs are waiting for you, View & apply to earn more.

  • Discord Bot

    $18, Hourly | Brazil
    I need a discord bot made that can send attachments, be used as a music-bot, have leveling and have a currency system.
  • UX testing / UI -amendments music sass platform

    $200, Fixed | United States
    I'm looking for a UX / UI person who's also a confident coder to help find errors with the workflows UX and UI in out sass platform . The site is a w...
  • Reverse engineer executable file

    $18, Hourly | Slovenia
    Ideally I want to retrieve source code from a 50kB machine code file, if it is possible
  • Triangular CryptoCurrency Arbitrage Bot for Bittrex

    $36, Hourly | Fiji
    Looking for a coder with experience in this space that has a working product that might just need to be tweaked or modified.
  • datababase analyse/visualisation/ pyhton dev

    $100, Fixed | France
    Looking for an experienced database proffesional who can help me out in some understandings problem where I am sucked with using Tableau. This contrac...
  • Python developer for automation

    $100, Fixed | Poland
    Looking for experienced Python developer to develop an website to provide a automation testing platform to software testing team. => Automation tool
  • Generative Adversarial Networks Implementation

    $150, Fixed | Ireland
    Looking for someone experienced in implementing Neural Networks/ Generative Adversarial Networks for an Academic Project.Would require implementation...
  • CSV to KMZ file conversion on Wordpress site

    $100, Fixed | Bangladesh
    Looking for someone to help me convert file formats to and from KMZ. Export to KMZ:User should be able to upload a CSV file to be converted to KMZ. Us...

People also searched for

Python Scripting – Learn and Earn
Python Scripting – Learn and Earn
Scripts & Utilities

Welcome to Python programming world! We presume you are trying to find information concerning why and how to get started with Python. Fortunately, an experienced coder in any progr...

Read More
Python script for computational science
Python script for computational science
Scripts & Utilities

Now a days, the popularity of scientific computing environments such as IDL, Maple, Mathematica, Matlab and R has increased considerably. Engineer simply feel more productive in su...

Read More
Everyone wants API expert
Everyone wants API expert
Scripts & Utilities

APIs became so valuable it comprises an oversized part of several businesses’ revenue. Major companies like Google, eBay,, Amazon, and Expedia are simply many of the...

Read More

You are freelancing Ninja?

Try Toogit Instant Connect today, The new virtual assistant for your freelancing world.

What is Python Script?

Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse.

What is a Python Script Freelancer?

Python is an interpreted, object-oriented and extensible programming language. Python can run on many different operating systems. A freelancer well versed in Python can handle your workload quite easily. To hire freelance programming help for Python post a job today!

What is a Freelancer?

A freelancer or freelance worker, is a term commonly used for a person who is self-employed and is not necessarily committed to a particular employer long-term.

Why hire a Freelancer instead of full time employee?

If there is a long lead time for them to get up and running, using that investment on a full-time employee might be a better option. And if the position requires oversight, hire an employee. A freelancer might choose to perform the work outside of normal business hours, when you're not able to monitor their progress.

What our users are discussing about Python