Software engineering best practices
Data science is tending to incorporate more software engineering these days, so it helps to understand some software engineering best practices.
Debugging errors and utilizing documentation
When running Python code (or any code from any language), we will inevitably run into problems. This usually manifests as errors that show up when we run the code, as in the following screenshot:
Figure 2.7: An example of an error in IPython. A number cannot be added to a string
In this case, we tried to add a number to text (a string). This is not allowed and gives us the error TypeError: unsupported operand type(s) for +: 'int' and 'str'
. If you can tell what the error is from the output, then you can try to fix it straight away. Otherwise, the most important part of the error is usually at the end/bottom of the output and is followed by something with an error, such as TypeError: <error message here>
, and will...