Writing Efficient Python Code
Learn to write efficient code that executes quickly and allocates resources skillfully to avoid unnecessary overhead.
Kurs Kostenlos Starten4 Stunden15 Videos52 Übungen
Kostenloses Konto erstellen
oder
Durch Klick auf die Schaltfläche akzeptierst du unsere Nutzungsbedingungen, unsere Datenschutzrichtlinie und die Speicherung deiner Daten in den USA.Trainierst du 2 oder mehr?Testen Sie DataCamp For Business
Beliebt bei Lernenden in Tausenden Unternehmen
Kursbeschreibung
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!
Für Unternehmen
Trainierst du 2 oder mehr?
Erhalten Sie für Ihr Team Zugriff auf die vollständige DataCamp-Bibliothek mit zentralisierten Berichten, Zuweisungen, Projekten und mehrIn den folgenden Tracks
Python Programmierung
Gehe zu Track- 1
Foundations for efficiencies
KostenlosIn 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.
Welcome!50 xpPop quiz: what is efficient50 xpA taste of things to come100 xpZen of Python50 xpBuilding with built-ins50 xpBuilt-in practice: range()100 xpBuilt-in practice: enumerate()100 xpBuilt-in practice: map()100 xpThe power of NumPy arrays50 xpPractice with NumPy arrays100 xpBringing it all together: Festivus!100 xp - 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.
Examining runtime50 xpUsing %timeit: your turn!100 xpUsing %timeit: specifying number of runs and loops50 xpUsing %timeit: formal name or literal syntax100 xpCode profiling for runtime50 xpPop quiz: steps for using %lprun50 xpUsing %lprun: spot bottlenecks50 xpUsing %lprun: fix the bottleneck50 xpCode profiling for memory usage50 xpPop quiz: steps for using %mprun50 xpUsing %mprun: Hero BMI50 xpUsing %mprun: Hero BMI 2.050 xpBringing it all together: Star Wars profiling100 xp - 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.
Efficiently combining, counting, and iterating50 xpCombining Pokémon names and types100 xpCounting Pokémon from a sample100 xpCombinations of Pokémon100 xpSet theory50 xpComparing Pokédexes100 xpSearching for Pokémon100 xpGathering unique Pokémon100 xpEliminating loops50 xpGathering Pokémon without a loop100 xpPokémon totals and averages without a loop100 xpWriting better loops50 xpOne-time calculation loop100 xpHolistic conversion loop100 xpBringing it all together: Pokémon z-scores100 xp - 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.
Intro to pandas DataFrame iteration50 xpIterating with .iterrows()100 xpRun differentials with .iterrows()100 xpAnother iterator method: .itertuples()50 xpIterating with .itertuples()100 xpRun differentials with .itertuples()100 xppandas alternative to looping50 xpAnalyzing baseball stats with .apply()100 xpSettle a debate with .apply()100 xpOptimal pandas iterating50 xpReplacing .iloc with underlying arrays100 xpBringing it all together: Predict win percentage100 xpCongratulations!50 xp
Für Unternehmen
Trainierst du 2 oder mehr?
Erhalten Sie für Ihr Team Zugriff auf die vollständige DataCamp-Bibliothek mit zentralisierten Berichten, Zuweisungen, Projekten und mehrIn den folgenden Tracks
Python Programmierung
Gehe zu TrackLogan Thomas
Mehr AnzeigenScientific Software Technical Trainer, Enthought
Was sagen andere Lernende?
Melden Sie sich an 14 Millionen Lernende und starten Sie Writing Efficient Python Code Heute!
Kostenloses Konto erstellen
oder
Durch Klick auf die Schaltfläche akzeptierst du unsere Nutzungsbedingungen, unsere Datenschutzrichtlinie und die Speicherung deiner Daten in den USA.