From the course: Python for Health Sciences and Healthcare
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Docstring - Python Tutorial
From the course: Python for Health Sciences and Healthcare
Docstring
- [Instructor] Let me show you something interesting. Import pandas. If we access the function like this, pandas dot double underscore doc double underscore. The function gives an output full of details. This tells us what pandas is, what it is used for. This is docstring. Essentially, a detailed comment about a function or class. Think of docstring like an internal guide. Let's look at another example. Let's say you want more information about read CSV, a common function in pandas to read CSV files. Just type help pandas.read-csv. The output is a detailed documentation of what read CSV is, including what the acceptable arguments and parameters are. So how can you replicate this in your code? You can make your own docstrings. They are accessible by the dunder doc and help function. For example, def total quantity dispensed. Total daily quantity, number of days. This function calculates the total quantity of medication…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.