ipython 学习笔记 1 基础

ref: Learning Ipython for interactive computing and data visualization

code website: http://ipython.rossant.net.

启动:

基础,可以用powershell在window下实现近似linux操作

notepad.exe 可代替vi啦

在shell下ipython notebook 可以启动notebook

chrome里输入http://localhost:8888/tree

就是我的notebook地址

一些简单指令:

Quick benchmarking with the %timeit command  

%timeit [x*x for x in range(100000)]

Quick debugging with the %debug command

to make the plot work

%matplotlib inline

Hot Keys

• Press the Enter key to create a new line in the cell and not execute the cell
• Press Shift + Enter to execute the cell and go to the next cell
• Press Alt + Enter to execute the cell and append a new empty cell right after it
• Press Ctrl + Enter for quick instant experiments when you do not want to
save the output
• Press Ctrl + M and then the H key to display the list of all the keyboard
shortcuts

Chapter 2

for python 3.4

from urllib.request import urlopen
html = ‘http://ipython.rossant.net/‘
filename = ‘facebook.zip‘
downloaded=urllib.request.urlopen(html+filename)
with open(filename, ‘wb‘) as f: f.write(download.read())
with zipfile.ZipFile(filename) as zip:zip.extractall(‘.‘)

bookmark a folder‘s path

%bookmark fbdata

then cd fbdata

lambda function

import sys
import os
# we retrieve the folder as the first positional argument
# to the command-line call
if len(sys.argv) > 1:
    folder = sys.argv[1]
# we list all files in the specified folder
files = os.listdir(folder)
# ids contains the sorted list of all unique idenfitiers
ids = sorted(set(map(lambda file: int(file.split(‘.‘)[0]), files)))

very cool interperation about this egos.py script

cmd line is:

%run egos.py facebook

"

Here is an explanation of what the last line does. The lambda function takes a filename as an argument following the template <egoid>.<extension>, and returns the egoid ID as an integer. It uses the split method of any string, which splits a string with a given character and returns a list of substrings, which are separated by this character. Here, the first element of the list is the <egoid> part. The map built-in Python function applies this lambda function to all filenames. The set function converts this list to a set object, thereby removing all duplicates and keeping only a list of unique identifiers (since any identifier appears twice with two different extensions). Finally, the sorted function converts the set object to a list, and sorts it in an increasing order.

"

debug

%run -d

%pdb
时间: 2024-07-29 19:31:28

ipython 学习笔记 1 基础的相关文章

大话设计模式学习笔记——面向对象基础

前言 好记性不如烂"笔头"系列--大话设计模式学习笔记 目录 面向对象基础 面向对象基础 什么是类与实例 一切事物皆为对象,即所有的东西老师对象,对象就是可以看到.感觉到.听到.触摸到.尝到.或闻到的东西.准确地说,对象是一个自包含的实体,用一组可识别的特性和行为来标识.面向对象编程,英文叫 Object-Oriented Programming,其实就是针对对象来进行编程的意思.类就是具有相同属性和功能的对象的抽象集合.实例就是一个真实的对象.比如我们属于'人'类,而个人就是'人'类

Java快速教程--vamei 学习笔记(基础篇)

链接:http://www.cnblogs.com/vamei/archive/2013/03/31/2991531.html java快速教程第1课 从HelloWorld到面向对象 学习网址:http://www.cnblogs.com/vamei/archive/2013/03/14/2958654.html java快速教程第2课 方法与数据成员 学习网址:http://www.cnblogs.com/vamei/archive/2013/03/25/2964430.html java快

C#学习笔记(基础知识回顾)之值类型与引用类型转换(装箱和拆箱)

一:值类型和引用类型的含义参考前一篇文章 C#学习笔记(基础知识回顾)之值类型和引用类型 1.1,C#数据类型分为在栈上分配内存的值类型和在托管堆上分配内存的引用类型.如果int只不过是栈上的一个4字节的值,该如何在它上面调用方法? 二:值类型转换为引用类型--装箱 2.1CLR对值类型进行装箱时:新分配托管堆内存,将值类型的实例字段拷贝到新分配的内存中,返回托管堆中新分配对象的地址.这个地址就是一个指向对象的引用. int i = 10; Object obj = i; 三:将引用类型转换为值

[Golong]学习笔记(一) 基础知识

Go编程基础 Go的内置关键字(25个) 不多 break default func interface select case defer go map struct chan else goto package switch const fallthrough if range type continute for import return var Go的注释方法(和js一样) 单行注释: // 多行注释: /**/ Go程序一般结构 common_structure.go 通过 pack

01-Python学习笔记-基础语法

Python标识符 -d           在解析时显示调试信息 -O           生成优化代码 ( .pyo 文件 ) -S           启动时不引入查找Python路径的位置 -v            输出Python版本号 -X           从 1.6版本之后基于内建的异常(仅仅用于字符串)已过时. -c cmd     执行 Python 脚本,并将运行结果作为 cmd 字符串. file           在给定的python文件执行python脚本. P

PHP:学习笔记(2)——基础语法

PHP:学习笔记(2)--基础语法 向屏幕输出 说明 1.void echo ( string $arg1 [, string $... ] ) 2.int print ( string $arg ) 注意: 1.echo.print 实际上不是一个函数(它是一个语言结构),因此你可以不必使用圆括号来括起它的参数列表. 2.输出变量的时候需要使用双引号! 3.int printf ( string $format [, mixed $args [, mixed $... ]] ) 4.strin

jQuery学习笔记——jQuery基础核心

代码风格 在jQuery程序中,不管是页面元素的选择.内置的功能函数,都是美元符号“$”来起始的.而这个“$”就是jQuery当中最重要且独有的对象:jQuery对象,所以我们在页面元素选择或执行功能函数的时候可以这么写: $(function () {}); //执行一个匿名函数 $(‘#box’);//进行执行的ID元素选择 $(‘#box’).css(‘color’, ‘red’);//执行功能函数由于$本身就是jQuery对象的缩写形式,那么也就是说上面的三段代码也可以写成如下形式:jQ

OpenFlow Switch学习笔记(一)——基础概念

OpenFlow Switch v1.4.0规范是在2013年10月14号发布,规范涵盖了OpenFlow Switch各个组件的功能定义.Controller与Switch之间的通信协议Open Flow Protocol等.下文主要是基于个人理解整理的一些学习笔记,理解不到位的地方还请大家多多指教. 一.基础概念图: 首先我们先看下Open Flow Switch的整体结构,以便有一个初步的感性认识,如下图所示: 从上面架构图中,我们可以看到Open Flow Switch主要是由以下几个部

.net学习笔记---xml基础知识

一.XML简介 XML是一种标记语言,用于描述数据,它提供一种标准化的方式来来表示文本数据.XML文档以.xml为后缀.需要彻底注意的是XML是区分大小写的. 先从一个简单的XML例子来了解下xml基础: <?xml version="1.0" encoding="utf-8" ?> <books ISBN="9787544238212"> <title>xml学习笔记</title> <pr