Skip to content

Instantly share code, notes, and snippets.

@ryanorsinger
Created September 23, 2019 19:47
Show Gist options
  • Save ryanorsinger/2b5eca9c491862ac4dcebe19d8cc0320 to your computer and use it in GitHub Desktop.
Save ryanorsinger/2b5eca9c491862ac4dcebe19d8cc0320 to your computer and use it in GitHub Desktop.
series_exercises

Make a file named pandas_series.py or pandas_series.ipynb for the following exercises.

Given ["kiwi", "mango", "strawberry", "pineapple", "gala apple", "honeycrisp apple", "tomato", "watermelon", "honeydew", "kiwi", "kiwi", "kiwi", "mango", "blueberry", "blackberry", "gooseberry", "papaya"]

  1. Create a pandas series called fruits to hold the above data.

  2. Run .describe() on the series to see what describe returns for a series of strings.

  3. Run the code necessary to produce only the unique fruit names.

  4. Determine how many times each value occurs in the series.

  5. Determine the most frequently occurring fruit name from the series.

  6. Determine the least frequently occurring fruit name from the series.

  7. Write the code to get the longest string from the fruits series.

  8. Find the fruit(s) with 5 or more letters in the name.

  9. Capitalize all the fruit strings in the series.

  10. Count the letter "a" in all the fruits (use string vectorization)

  11. Output the number of vowels in each and every fruit.

  12. Use the .apply method and a lambda function to find the fruit(s) containing two or more "o" letters in the name.

  13. Write the code to get only the fruits containing "berry" in the name

  14. Write the code to get only the fruits containing "apple" in the name

  15. Which fruit has the highest amount of vowels?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment