Objective
Set up a development environment for Python data science applications.
Tools
Anaconda
Anaconda is a Python distribution that includes the most popular data science packages out of the box (e.g., numpy, pandas, scipy, scikit-learn).
Visual Studio Community 2017
The installation of VS 2017 is very modular. For the content of this article, only the Python development tools need to be installed.
Visual Studio has several convenient features for Python development: IntelliSense, build-in interactive window, excellent debugging tools, management of multiple Python environments.
Steps
Open Visual Studio and create a new Python project (use the Python Application template to create an empty application).
In the Solution Explorer, expand the Python Environments item and verify which Python environment is associate to the project. If it is not Anaconda by default, right click on Python Environments, select Add/Remove Python Environments and select Anaconda.
If IntelliSense is not working correctly, you may need to refresh the database. Open the Python Environments view and select Anaconda. Select IntelliSense in the dropdown and press Refresh DB.
At this point, you are ready to go! You can test your system with this simple code that plots a sine wave.
import numpy as np import matplotlib.pyplot as plt x = np.linspace(-10, 10, 200) y = np.sin(x) plt.scatter(x,y) plt.show()
You can launch the program by pressing the green play button as usual, or you can execute it in the interactive window. We will follow the second approach. Select your code, right click, and press Send to Interactive. The code will be copied into the interactive window and it will execute, displaying the plot of the sine wave.
This is just a very basic example, but you are all set up for more advanced data science applications. Refer to the recommended reading section to learn more.
Recommended Reading
Python Data Science Handbook (ISBN: 1491912057)
Excellent introduction to NumPy, Pandas, Matplotlib and Scikit-Learn.
Learning SciPy for Numerical and Scientific Computing, Second Edition (ISBN: 1783987707)
Concise introduction to NumPy and SciPy for various applications.
Leave a Reply