1. 使用 pandas 中的函数,下载上证综指过去一段时间的数据,进行数据探索。
上证综指,全称是上海证券综合指数,是以上证所挂牌上市的全部股票为计算范围,以发行量为权数的加权综合股价指数。这一指数自1991年7月15日起开始实时发布,基日定为1990年12月19日,基日指数定为100点。
注:该文是上了开智学堂数据科学基础班的课后做的笔记,主讲人是肖凯老师。
为什么要做数据可视化?因为可视化后获取信息的效率高。为什么可视化后获取信息的效率就高?因为人眼是个高带宽的巨量信号输入并行处理器,具有超强的模式识别能力,对可视符号的感知速度比对数字或文本快多个数量级,而可视化就是迎合了人眼的这种特点,才使得获取信息难度大大降低。(获取信息难度大大降低,也就是学习难度降低,也就能以有限的精力学到更多的东西,从而提高学习效率,所以可视化做得好就可以大大提高学习效率……)
1. 绘制一个二维随机漫步的图形
直接上代码:
%pylab inline
nsteps = 1000
draws = np.random.randint(-1,2,size=(2,nsteps))
walks = draws.cumsum(1)
plot(walks[0,:],walks[1,:]);
Populating the interactive namespace from numpy and matplotlib
创建向量有许多方法,举例说明:
import numpy as np
print(np.array([2,3,4])) # 可以从列表转换而来,np.array 会尝试为数组推断出一个较为合适的数据类型
[2 3 4]
print(np.zeros( (3,4) , dtype=np.int32)) # zeros 可以创建指定长度或形状的全 0 数组
[[0 0 0 0]
[0 0 0 0]
[0 0 0 0]]
1. 使用循环和向量化两种不同的方法来计算 100 以内的质数之和。
先定义个判断质数的函数。ps:纯手工打造,原生态,哈哈。
def checkprime(x):
if x<=1:
return False;
prime=True;
for i in range(2 , 1+x/2):
if x%i == 0:
prime = False;
break;
return prime;
先来瞎想下,哪些方面能体现人们的生活水平变化?从物质层面上说,吃饱穿暖了,吃肉喝酒不是问题了,开上车了,开上好车了,住上好房子了,超市、商场物品极大丰富,饭店、宾馆、租车店等各种服务应有尽有,遍地开花,从精神层面上说,电视节目五花八门,无所不包,电影作品层出不穷,网上论坛、博客、微博、微信大大促进了人们的信息分享和交流,极大满足了人们的心理需求,图书市场也是好作品不断,所有这些都能体现人们生活水平的提高,还有从人们的脸色和形体动作所体现出来的精神风貌也能体现出人们生活水平的变化。
时间:2006年3月1日下午
地点:英国议会下院
时段:Prime Minister’s Questions
事件:Tony Blair and David Cameron,气氛很融洽,因为卡梅伦生了个儿子
Mr. David Cameron (Witney) (Con): May I join the Prime Minister in expressing our sympathy for the families of the two British soldiers who died in Iraq yesterday? They died serving our country, and we should honour their memory. I also agree with what the Prime Minister said about Mr. Speaker, and wish him a speedy return.
时间:2007年3月7日下午
地点:英国议会下院
时段:Prime Minister’s Questions
事件:Tony Blair vs David Cameron,George Osborne和David Cameron分别在同性恋和气候大会问题上被调侃。
Mr. David Cameron (Witney) (Con): Last night, the BBC broadcast the Prime Minister’s political obituary; I am sure that it will be the first of many. In it, his senior foreign policy adviser in No. 10 Downing street, Sir Stephen Wall, speaking of his time working with the Prime Minister, said:
“You got the very clear impression...that they could not govern without Gordon but they could not really govern with him either”.
Why would someone at the heart of Downing street say that?
时间:2006年5月17日下午
地点:英国议会下院
时段:Prime Minister’s Questions
事件:Tony Blair vs David Cameron。布莱尔答辩时,坐在卡梅伦旁边的保守党财政事物发言人George Osborne插嘴,结果遭到布莱尔深刻鄙视。
Mr. David Cameron (Witney) (Con): On behalf of the Opposition, may I add our sympathies to what the Prime Minister said about the soldiers who gave their lives in Iraq? Our thoughts should be with their families for what they have done on our behalf.
Two weeks ago the Prime Minister said that automatic deportation would apply to any foreign national
“convicted of an imprisonable offence”.—[ Official Report,3 May 2006; Vol. 445, c. 960.]
Last week he said it would apply to those actually imprisoned. This week the Home Secretary said that automatic deportation would now apply only to foreign nationals serving a “significant” jail term. Which is it?
时间:2006年5月10日下午
地点:英国议会下院
时段:Prime Minister’s Questions
事件:Tony Blair vs David Cameron
Mr. David Cameron (Witney) (Con): I join the Prime Minister in paying tribute to the servicemen and women who died in Iraq. They were serving their country.
Three weeks ago, I asked the Prime Minister about the crisis in children’s hospitals. He said that everything was fine so can he explain why the Minister responsible for hospitals has resigned?