project
Writing Functions for Product Analysis
Use coding best practices and functions to improve a script!
Start Project for Free8 Tasks1,500 XP4,506
Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.Training 2 or more people?Try DataCamp For Business
Loved by learners at thousands of companies
Project Description
Have you ever started your data analysis and ended up with repetitive code? Repetitive code is a sign that functions are needed. Functions help keep our code flexible, maintainable, and interpretable.
Our colleague Brenda, a product analyst, has written a script to pull Net Promotor Score (NPS) survey data from multiple sources to calculate the NPS score. This code works well, but it violates coding best practices, including Don't Repeat Yourself (DRY). Let's take a look at her code and write some functions for Brenda! To complete this project, you need to know how to write functions in Python and how to use pandas for DataFrame manipulation.
Project Tasks
- 1DRY: Don't repeat yourself
- 2Verifying the files with the "with" keyword
- 3Putting it together with nested functions
- 4Detractors, Passives, and Promoters
- 5Applying our function to a DataFrame
- 6Calculating the Net Promoter Score
- 7Breaking down NPS by source
- 8Adding docstrings
Technologies
Python
Topics
ProgrammingLis Sulmont
See MoreContent Program Manager at Duolingo
Lis holds a Master's degree in Computer Science from McGill University with a focus on computer science education research and applied machine learning. She's passionate about teaching all things related to data and improving the accessibility of these topics.