Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with itsinterpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
This tutorial introduces the reader informally to the basic concepts and features ofthe Python language and system. It helps to have a Python interpreter handy forhands-on experience, but all examples are self-contained, so the tutorial canbe read off-line as well.
How to Think Like a Computer Scientist: Interactive Edition
The goal of this book is to teach you to think like a computerscientist. This way of thinking combines some of the best features ofmathematics, engineering, and natural science.
Like mathematicians, computerscientists use formal languages to denote ideas (specifically computations).
Like engineers, they design things, assembling components into systems andevaluating tradeoffs among alternatives.
Like scientists, they observe thebehavior of complex systems, form hypotheses, and test predictions.
The single most important skill for a computer scientist isproblem solving. Problem solving means the ability to formulate problems, thinkcreatively about solutions, and express a solution clearly and accurately. As it turns out, the process of learning to program is an excellent opportunity topractice problem solving skills.
On one level, you will be learning to program, a useful skill byitself. On another level, you will use programming as a means to an end. As wego along, that end will become clearer.
Tutorials for Python libraries
Matplotlib is the oldest and most widely-used Python library fordata visualization. It was created by neurobiologist John D. Hunter to plotdata of electrical activity in the brains of epilepsy patients, but today isused in a number of fields.
When analysts and data scientists use matplotlib, they’re usuallyusing it in tandem with other Python libraries. Matplotlib is designed to workwith NumPy, a numerical mathematics library and is a core part of the SciPystack—a group of scientific computing tools for Python.
NumPy is a scientific computing library for Python. It offershigh-level mathematical functions and a multi-dimensional structure (know asndarray) for manipulating large data sets.
While NumPy on its own offers limited functions for data analysis,many other libraries that are key to analysis—such as SciPy, matplotlib, andpandas are heavily dependent on NumPy.
Pandas is a Python library for data analysis. Started by WesMcKinney in 2008 out of a need for a powerful and flexible quantitative analysis tool, pandas has grown into one of the most popular Python libraries.It has an extremely active community of contributors.
Pandas is built on top of two core Python libraries—matplotlib fordata visualization and NumPy for mathematical operations. Pandas acts as awrapper over these libraries, allowing you to access many of matplotlib’s and NumPy’s methods with less code. For instance, pandas’ .plot() combines multiple matplotlib methods into a single method, enabling you to plot a chart in a few lines.
SciPy is a Python library used for scientific computing and statistical analysis. It was created by Travis Oliphant, Eric Jones, and PearuPeterson in 2001 as part of the effort to create a complete scientific computing environment in Python. This environment is known as the SciPy stack,and includes NumPy, matplotlib, and pandas.
SciPy is most commonly used in academic fields such as earth science and astronomy, but data scientists might find its linear algebra module useful.
Although SciPy and NumPy are sometimes referred to interchangeably, they’re not the same. SciPy is a set of numerical operations built on top of NumPy’s ndarray.
In addition to the library and stack of tools, SciPy also refers tothe SciPy community and a group of conferences dedicated to scientific computing in Python—such as SciPy or EuroSciPy.
Seaborn is a Python visualization library for statistical plotting.It comes equipped with preset styles and color palettes so you can createcomplex, aesthetically pleasing charts with a few lines of code. It’s designed to work with NumPy and pandas data structures and to support statistical tasks completed in SciPy and stats models.
Seaborn is built on top of Python’s core visualization librarymatplotlib, but it’s meant to serve as a complement, not a replacement. In most cases, you’ll still use matplotlib for simple plotting, and you’ll need aknowledge of matplotlib to tweak Seaborn’s default plots.
More Seaborn Tutorial
As its name implies, stats models is a Python library built specifically for statistics. Statsmodels is built on top of NumPy, SciPy, and matplotlib, but it contains more advanced functions for statistical testing and modeling that you won’t find in numerical libraries like NumPy or SciPy.