Python 初识Pandas- Python Data Analysis Library
学习资料来自于
1. Coursera 《用Python 玩转数据》 https://www.coursera.org/learn/hipython
2. 网站:http://pandas.pydata.org/
Pandas Series
>>> from pandas import Series >>> sa = Series(['a', 'b', 'c'], index = [0, 1, 2]) >>> sb = Series(['a', 'b', 'c']) >>> sc = Series(['a', 'c', 'b']) >>> sa.equals(sc) False >>> sb.equals(sa) True >>> sa*3 + sc*2 0 aaaaa 1 bbbcc 2 cccbb >>> from pandas import Series, DataFrame >>> data = {'language': ['Java', 'PHP', 'Python', 'R', 'C#'], 'year': [ 1995 , 1995 , 1991 ,1993, 2000]} >>> frame = DataFrame(data) >>> frame['IDE'] = Series(['Intellij', 'Notepad', 'IPython', 'R studio', 'VS']) >>> 'VS' in frame['IDE'] False >>> frame.ix[2] language Python year 1991 IDE IPython Name: 2, dtype: object |
frame.ix[2]表示取frame中的第三行数据。
frame.ix[i]表示取frame中的第i+1行数据。
Pandas DataFrame
1. 从雅虎财经获取上市公司股票历史数据,获取从两年前的今天到今天的微软公司的股票数据。
微软公司的公司代号可从