[Tutor] Delete unwanted rows
ap235711 at gmail.com
Wed Apr 9 11:23:09 CEST 2014
My question is whether I should write a loop or a function to delete rows.
I'm using pandas. But you may be able to help me as my question is about
the reasoning behind programming.
I have a pandas dataframe that looks like this, covering all countries in
the world, for over 200 rows and many columns:
Saint Kitts 90
Saint Martins 133
Saint Helena 166
# So I write a list of small countries that I wish to exclude from my
analysis. What I want to do is to delete the rows from my dataframe.
toexclude = ['Martinique', 'Saint Kitts', 'Saint Martins', 'Saint
After this, should I write a loop to loop through the dataframe, find the
countries that I want to delete, and then delete the rows?
Or should I write a function, which deletes those rows, and then returns me
a new and trimmed dataframe?
Thank you for helping me figure this out.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor