Interactive Course

Writing Efficient Python Code

Learn to write efficient code that executes quickly and allocates resources skillfully to avoid unnecessary overhead.

  • 4 hours
  • 15 Videos
  • 53 Exercises
  • 5,326 Participants
  • 4,050 XP

Loved by learners at thousands of top companies:

siemens-grey.svg
whole-foods-grey.svg
roche-grey.svg
lego-grey.svg
axa-grey.svg
credit-suisse-grey.svg

Course Description

As a Data Scientist, the majority of your time should be spent gleaning actionable insights from data -- not waiting for your code to finish running. Writing efficient Python code can help reduce runtime and save computational resources, ultimately freeing you up to do the things you love as a Data Scientist. In this course, you'll learn how to use Python's built-in data structures, functions, and modules to write cleaner, faster, and more efficient code. We'll explore how to time and profile code in order to find bottlenecks. Then, you'll practice eliminating these bottlenecks, and other bad design patterns, using Python's Standard Library, NumPy, and pandas. After completing this course, you'll have the necessary tools to start writing efficient Python code!

  1. 1

    Foundations for efficiencies

    Free

    In this chapter, you'll learn what it means to write efficient Python code. You'll explore Python's Standard Library, learn about NumPy arrays, and practice using some of Python's built-in tools. This chapter builds a foundation for the concepts covered ahead.

  2. Gaining efficiencies

    This chapter covers more complex efficiency tips and tricks. You'll learn a few useful built-in modules for writing efficient code and practice using set theory. You'll then learn about looping patterns in Python and how to make them more efficient.

  3. Timing and profiling code

    In this chapter, you will learn how to gather and compare runtimes between different coding approaches. You'll practice using the line_profiler and memory_profiler packages to profile your code base and spot bottlenecks. Then, you'll put your learnings to practice by replacing these bottlenecks with efficient Python code.

  4. Basic pandas optimizations

    This chapter offers a brief introduction on how to efficiently work with pandas DataFrames. You'll learn the various options you have for iterating over a DataFrame. Then, you'll learn how to efficiently apply functions to data stored in a DataFrame.

  1. 1

    Foundations for efficiencies

    Free

    In this chapter, you'll learn what it means to write efficient Python code. You'll explore Python's Standard Library, learn about NumPy arrays, and practice using some of Python's built-in tools. This chapter builds a foundation for the concepts covered ahead.

  2. Timing and profiling code

    In this chapter, you will learn how to gather and compare runtimes between different coding approaches. You'll practice using the line_profiler and memory_profiler packages to profile your code base and spot bottlenecks. Then, you'll put your learnings to practice by replacing these bottlenecks with efficient Python code.

  3. Gaining efficiencies

    This chapter covers more complex efficiency tips and tricks. You'll learn a few useful built-in modules for writing efficient code and practice using set theory. You'll then learn about looping patterns in Python and how to make them more efficient.

  4. Basic pandas optimizations

    This chapter offers a brief introduction on how to efficiently work with pandas DataFrames. You'll learn the various options you have for iterating over a DataFrame. Then, you'll learn how to efficiently apply functions to data stored in a DataFrame.

What do other learners have to say?

Devon

“I've used other sites, but DataCamp's been the one that I've stuck with.”

Devon Edwards Joseph

Lloyd's Banking Group

Louis

“DataCamp is the top resource I recommend for learning data science.”

Louis Maiden

Harvard Business School

Ronbowers

“DataCamp is by far my favorite website to learn from.”

Ronald Bowers

Decision Science Analytics @ USAA

Logan Thomas
Logan Thomas

Senior Data Scientist at Protection Engineering Consultants

Logan is a member of the Engineering Analytics team at Protection Engineering Consultants – an organization that provides engineering services and products for mitigation and protection against hazards, extraordinary events and attacks for hundreds of industry clients and dozens of government and military customers worldwide. As a Senior Associate Data Scientist, he focuses on writing robust, scalable, and efficient Python code to empower decision making. As a self-proclaimed Python enthusiast, Logan enjoys attending meetups and conferences in the Austin, Texas area to share his knowledge with others.

See More
Icon Icon Icon professional info