Data Science in cloud Ipython and pandas investment analysis

Source: Internet
Author: User
Keywords Ipython pandas investment analysis

This article will introduce some practical examples using IPython and pandas for investment analysis and http://www.aliyun.com/zixun/aggregation/10341.html "> Statistical analysis."

Let's do a common analysis and you may be able to do it yourself. Suppose you want to analyze stock performance, you can:

is looking for a stock in Yahoo financial zone. Download historical data and save it in CSV file format. Import the CSV file into Excel. Perform mathematical analysis: regression, descriptive statistics or linear optimization using Excel solver tools.

Good, but this article shows you a simpler, more intuitive, more powerful way to use IPython and pandas for the same kind of analysis.

The IPython Library is one of the most important tools for using Python data scientists. The biggest difference between this tool and Excel is that you can use it to interactively explore data and analysis from an interactive prompt. The examples in this article mainly use IPython as a mechanism to run them.

The Python Data Analysis Library (PANDAS) is a BSD-licensed open Source library that provides high-performance, easy-to-use data structures and data analytics tools for the Python programming language.

Started

When you start using IPython and pandas, you need to set up your Linux or Unix operating system, such as Ubuntu or OS X.

The

installation Pip,pip is a tool for installing and managing Python packets. You may have used Easy_install before, but the PIP has now replaced Easy_install. To install the PIP, go to the PIP index page of the Python Web site and follow the instructions. After the PIP is installed, use the following command to install the Ipython:sudo pip install IPython use pip to install Pandas:sudo pip Install Pandas there is also an installation tool-matplotlib, which is a Python programming language and its NumPy graphics library for numerical mathematical expansion. Please use the following command: sudo pip install matplotlib

Now that you've done all the steps you need, let's start using IPython and Pandas!

Pandas introduction

To enter your portfolio data into pandas, use the following code:

Listing 1. Pandas Combination Data Import

in [1]: Import pandas.io.data as Web into [2]: From pandas import dataframe in [3]: Data_feed = {} in [4]: symbols=[' AAPL ', ' FB ' , ' GOOG ', ' splk ', ' YELP ', ' GG ', ' BP ', ' SCPJ ', ' JNJ ', ' OMG '] in [5]: for ticker in symbols: ...: data_feed[ticker] = Web.get_data _yahoo (Ticker, ' 05/21/2012 ', ' 11/1/2012 ') ...: in [6]: Price = Dataframe ({tic:data[' Adj close '] ...: for tic, data in Data_ Feed.iteritems ()}) in [7]: volume = Dataframe ({tic:data[' volume '] ...: for tic, data in Data_feed.iteritems ()}) in [8]: returns = Price.pct_change ()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.