Skip to main content
HomePythonWriting Efficient Python Code

Writing Efficient Python Code

4.7+
48 reviews
Intermediate

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

Start Course for Free
4 Hours15 Videos53 Exercises
120,011 LearnersTrophyStatement of Accomplishment

Create Your Free Account

GoogleLinkedInFacebook

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.
GroupTraining 2 or more people?Try DataCamp For Business

Loved by learners at thousands of companies


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!
For Business

GroupTraining 2 or more people?

Get your team access to the full DataCamp library, with centralized reporting, assignments, projects and more
Try DataCamp for BusinessFor a bespoke solution book a demo.

In the following Tracks

Certification Available

Data Engineer in Python

Go To Track

Python Programming

Go To Track
  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.

    Play Chapter Now
    Welcome!
    50 xp
    Pop quiz: what is efficient
    50 xp
    A taste of things to come
    100 xp
    Zen of Python
    50 xp
    Building with built-ins
    50 xp
    Built-in practice: range()
    100 xp
    Built-in practice: enumerate()
    100 xp
    Built-in practice: map()
    100 xp
    The power of NumPy arrays
    50 xp
    Practice with NumPy arrays
    100 xp
    Bringing it all together: Festivus!
    100 xp
  2. 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.

    Play Chapter Now
For Business

GroupTraining 2 or more people?

Get your team access to the full DataCamp library, with centralized reporting, assignments, projects and more

In the following Tracks

Certification Available

Data Engineer in Python

Go To Track

Python Programming

Go To Track

Datasets

Baseball statistics

Collaborators

Collaborator's avatar
Chester Ismay
Collaborator's avatar
Becca Robins
Logan Thomas HeadshotLogan Thomas

Scientific Software Technical Trainer, Enthought

See More

Don’t just take our word for it

*4.7
from 48 reviews
81%
13%
4%
2%
0%
Sort by
  • Lyndon H.
    3 months

    As someone who started coding in Assembler, I've always used looping when coding and was interested to see that alternative means were available. To paraphrase Monty Python "your loopings or your life" (Dennis Moore).

  • Alexis M.
    3 months

    This was a hole in my knowledge and I really liked how this course built up to more efficient techniques. I’ll definitely be using the notes I made for this course in the future!

  • PASCAL P.
    5 months

    Very interesting and helpful course which gives different ways to make Python code more efficient

  • Richard R.
    7 months

    Having been writing python for 3 years. This basic understanding of the built in python functions and efficient code writing has been a great help.

  • Ahmed o.
    8 months

    .

"As someone who started coding in Assembler, I've always used looping when coding and was interested to see that alternative means were available. To paraphrase Monty Python "your loopings or your life" (Dennis Moore)."

Lyndon H.

"This was a hole in my knowledge and I really liked how this course built up to more efficient techniques. I’ll definitely be using the notes I made for this course in the future!"

Alexis M.

"Very interesting and helpful course which gives different ways to make Python code more efficient"

PASCAL P.

FAQs

Join over 14 million learners and start Writing Efficient Python Code today!

Create Your Free Account

GoogleLinkedInFacebook

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.