Python for Data Analysis (9)

魔法命令

a=1;b=100
a*b

%timeit a*b
The slowest run took 15.46 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 201 ns per loop
import numpy as np
a=np.random.randn(100,100)
%timeit np.dot(a,a)
%time np.dot(a,a)
The slowest run took 1636.68 times longer than the fastest. This could mean that an intermediate result is being cached.
10000 loops, best of 3: 46.3 µs per loop
CPU times: user 93 µs, sys: 1e+03 ns, total: 94 µs
Wall time: 73 µs





array([[  1.6460291 ,   8.04479056,   3.55858006, ...,  -5.11887218,
         -2.34480825,   0.29470307],
       [ -2.31945251, -19.91884282, -16.80738536, ...,  -5.11245243,
          5.26080793,   2.11886289],
       [  3.14523094,  10.21521818,   9.28415132, ...,  -8.38065148,
         17.53078937,  -7.68667463],
       ..., 
       [ 13.92807526,  13.70927476, -14.50414208, ...,   0.71719941,
          6.33660503,  -6.9980424 ],
       [  9.13700782,   1.43313504,  -1.26994739, ...,   8.07787293,
         14.41700316,   5.32727609],
       [  1.38417926,  17.93342167,   2.68956568, ..., -11.20007195,
        -14.31456352,   4.74833645]])

插入图片

from IPython.display import Image
Image(filename="pic/magic1.png")

这里写图片描述

Image(filename="pic/magic2.png")

这里写图片描述

插入Latex

from IPython.display import Latex
Latex("$Z=\sqrt{x^2+y^2}$")

Z=x2+y2

%hist #查看历史输入
%logstart #日志记录开始,有一个系列:%logoff,logon,logstate,logstop
Activating auto-logging. Current session state plus future input saved.
Filename       : #日志记录开始,有一个系列:%logoff,logon,logstate,logstop
Mode           : backup
Output logging : False
Raw input log  : False
Timestamping   : False
State          : active
%logoff #日志记录结束
Switching logging OFF
Image('pic/magic3.png') #其中带!的命令表示是其后面的内容需要在系统shell中执行,这个很厉害,打通了Ipython和shell的沟通

这里写图片描述

Image('pic/magic4.png')

png

#%alias ,可以为shell命令自定义简称
%alias ll ls -l
ll
total 162160
-rw-r--r--  1 momo  staff       636  9 19 21:25 #日志记录开始,有一个系列:%logoff,logon,logstate,logstop
-rw-r--r--  1 momo  staff      1414  9  9 16:02 Python for Data Analysis (1).ipynb
-rw-r--r--  1 momo  staff     13654  9 11 11:39 Python for Data Analysis (2).ipynb
-rw-r--r--  1 momo  staff      5288  9 11 23:38 Python for Data Analysis (3).ipynb
-rw-r--r--  1 momo  staff      7618  9 12 10:09 Python for Data Analysis (4).ipynb
-rw-r--r--  1 momo  staff      5462  9 12 22:38 Python for Data Analysis (5).ipynb
-rw-r--r--  1 momo  staff      3284  9 13 23:49 Python for Data Analysis (6).ipynb
-rw-r--r--  1 momo  staff      4815  9 16 09:36 Python for Data Analysis (7).ipynb
-rw-r--r--  1 momo  staff      6022  9 19 19:36 Python for Data Analysis (8).ipynb
-rw-r--r--  1 momo  staff    714346  9 19 21:29 Untitled.ipynb
-rw-r--r--  1 momo  staff      1020  9 19 21:15 ipython_log.py
drwxr-xr-x  6 momo  staff       204  9 19 21:17 [34mpic[m[m
-rwxr-xr-x@ 1 momo  staff  82233792  9 19  2015 [31m利用Python进行数据分析.pdf[m[m
#还可以一次性定义多条为一个命令!!!太牛了
#只需用分号将多个命令隔开
%alias test_alias (cd pic;ls)
%test_alias
magic1.png magic2.png magic3.png magic4.png
这本书主要是用 pandas 连接 SciPy 和 NumPy,用pandas做数据处理是Pycon2012上一个很热门的话题。另一个功能强大的东西是Sage,它将很多开源的软件集成到统一的 Python 接口。, Python for Data Analysis is concerned with the nuts and bolts of manipulating, processing, cleaning, and crunching data in Python. It is also a practical, modern introduction to scientific computing in Python, tailored for data-intensive applications. This is a book about the parts of the Python language and libraries you’ll need to effectively solve a broad set of data analysis problems. This book is not an exposition on analytical methods using Python as the implementation language., Written by Wes McKinney, the main author of the pandas library, this hands-on book is packed with practical cases studies. It’s ideal for analysts new to Python and for Python programmers new to scientific computing., Use the IPython interactive shell as your primary development environment, Learn basic and advanced NumPy (Numerical Python) features, Get started with data analysis tools in the pandas library, Use high-performance tools to load, clean, transform, merge, and reshape data, Create scatter plots and static or interactive visualizations with matplotlib, Apply the pandas groupby facility to slice, dice, and summarize datasets, Measure data by points in time, whether it’s specific instances, fixed periods, or intervals, Learn how to solve problems in web analytics, social sciences, finance, and economics, through detailed examples
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值