<jupyter_start><jupyter_text>Basic of IPython<jupyter_code>a = 5
a
import numpy as np
from numpy.random import randn
data = {i : randn() for i in range(7)}
data
b = [1, 2, 3]
c = [4, 5, 6]
b.append(c)
b<jupyter_output><empty_output><jupyter_text>？内省<jupyter_code>def add_numbers(a,b):
    """
    Add two numbers together"""
    return a+b
# show source code
# add_numbers??<jupyter_output><empty_output><jupyter_text>搜索命名空间，用通配符<jupyter_code>#np.*load*?<jupyter_output><empty_output><jupyter_text>**!** 开头可执行cmd 命令<jupyter_code>! ipconfig/all
def add_numbers(a,b):
    """
    Add two numbers together"""
    return a+b
print (add_numbers(2,3))<jupyter_output>5<jupyter_text>%paste doesn't work here.  Magic Command %timeit 检测语句的执行时间<jupyter_code>a = np.random.randn(100,100)
%timeit np.dot(a, a)
%reset?<jupyter_output><empty_output><jupyter_text>magic command可以没有% 当没有同名的变量冲突时。这称为automagic<jupyter_code>%quickref
%magic #show docs of all magic commands
2**27
2**2<jupyter_output><empty_output><jupyter_text>最近的两个输出结果保存在: _ __<jupyter_code>_
foo = 'bar'
foo
_i88
_88
%logstart
ip_info = !ipconfig/all
ip_info
%debug
strings = ['foo', 'foobar', 'baz'] *100000
%time method1 = [x for x in strings if x.startswith('foo')]
%time method2 = [x for x in strings if x[:3] == 'foo']
%timeit [x for x in strings if x.startswith('foo')]
%timeit [x for x in strings if x[:3] == 'foo']<jupyter_output>25.8 ms ± 586 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
{'fraction_non_alphanumeric': 0.14736120630568883, 'fraction_numerical': 0.030843043180260453, 'mean_word_length': 6.192118226600985, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '517026', 'license': 'MIT', 'n_tokens_mistral': 680, 'n_tokens_neox': 665, 'n_words': 146, 'path': '.ipynb_checkpoints/ch03-checkpoint.ipynb', 'repo_name': 'zzy2008/pyDataAnalysis', 'size': '1459'}