Python – Filtering values from a Pandas DataFrame

Some time ago, probably yesterday or the day before, I had to filter a pandas dataframe and somehow it did not come intuitively into my mind how to do it. As I did not have an article about it, I decided to write one, as this problems will be something I will be seeing a lot.

Prague. Czech Republic. Nothing to do with Python, just a nice picture

Anyway, let’s assume this is our input table:

These are the tasks we need to fulfill:

  1. Remove the null values from going_from and going_to
  2. Display the data with removed null values
  3. Display the data with removed null values only
  4. Remove rows where either “VitoshAcademy” or “Academy” is present
  5. Display the rest of the rows

That’s all!

Tagged with: , , ,