Hello,
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:
Canada 20
China 112
Germany 10
Japan 12
Martinique 140
Mexico 180
Saint Kitts 90
Saint Martins 133
Saint Helena 166
USA 18
# 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
Helena']
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.
Alexis
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor