Python for Data Science - Introduction
Python was released with philosophy which emphasizes simplicity, code readibility and efficiency.Being an Object Oriented Programming language python groups data and code into objects that can interact with and modify one another. Data Science is small portion with in diverse python ecosystem. Python has deep learning and machine learning libraries which includes scikit-learn, Keras and tensorflow.
Help and Documentation in python:
Every python object contains the reference to a string, known as doc string, which contain a concise summary of the object and how to use it. Python has built-in help()
function that can access this information and prints the result.
For example to see the documentation of built-in function len()
:-
help(len)
## Help on built-in function len in module builtins:
##
## len(obj, /)
## Return the number of items in a container.
👉 In Ipython the other option is to use
?
character as a shorthand for accessing the documentation and other relevant information.
Note that this help()
function or ?
shorthand also works for functions and other objects which we create by ourself.
Lets define a simple function with a docstring.
def cube(a):
"""Return the cube of a. """
return a ** 3
Now we will use help()
function to find the docstring.
help(cube)
## Help on function cube in module __main__:
##
## cube(a)
## Return the cube of a.
👉This quick access to documentation via docstrings is one reason you should get in the habit of always adding such inline documentation to the code you write!
Important Points regarding help and documentation.
- To read the source code of the object use
??
shorthand in Ipython.
- To see a list of all available attributes of an object type the name of object followed by a period
.
character and the TAB key.L.<TAB>
- To list private/internal attributes or methods by explicitly typing the underscrore.
L._<TAB>