Yangtao's Python/jupyter study notes

Source: Internet
Author: User
Tags install pandas jupyter jupyter notebook install matplotlib

Yangtao's Python/jupyter study notes
    • Python Grammar Learning https://zhuanlan.zhihu.com/p/24162430
Python Installation Library installation Jupyter Notebook
    1. Install Python First
    2. cmd into K:\Jupyter Notebook python\python_3.6.4\scripts directory
    3. CMD input pip install jupyter start installation
    4. Run the Jupyter-notebook.exe under Python_3.6.4\scripts
Installing the NumPy Math Pack
    1. To https://pypi.python.org/pypi/numpy#downloads download the corresponding version of the NUMPY-1.14.0-CP36-NONE-WIN_AMD64.WHL file, copy it to the scripts directory to install
      CMD runs on K:\Jupyter Notebook python\python_3.6.4\scripts>

    2. Pip Install NUMPY-1.14.0-CP36-NONE-WIN_AMD64.WHL

Installing the Drawing Package matplotlib
    1. CMD input pip install Matplotlib
Installing the Pandas data input and output library
    1. CMD input pip Install pandas
Installing the Seaborn Drawing Library
    1. CMD input pip install Seaborn
Pip Install command
    1. Install pip install Jupyterthemes
    2. Install the latest version pip install--upgrade jupyterthemes
    3. Install the specified version pip install jupyterthemes==0.18.3

    4. In fact, Pip instal can be installed locally. WHL can also be installed online
    5. If the online installation fails, such as Unicodedecodeerror: ' GBK ' codec can ' t decode such issues. You may need to install the previously specified version

import
math.sin(3)
0.1411200080598672
= ['cat''window''defenestrate']forin words:    print("单词 "+"长度"+str(len(w)))
单词 cat 长度3单词 window 长度6单词 defenestrate 长度12
# 绘图包 matplotlib 的使用# https://liam0205.me/2014/09/11/matplotlib-tutorial-zh-cn/# http://codingpy.com/article/a-quick-intro-to-matplotlib/importas# 需要先包含绘图包 importas= np.arange(20= x**2# 显示图形#参考 http://codingpy.com/article/a-quick-intro-to-matplotlib/

$$ \int_0^{+\infty} x^2 DX $$

# 自定义曲线的外观= np.linspace(02*50'r-o',        'g--')   # r g 颜色   - 线型plt.show()

# 彩色映射散点图= np.random.rand(1000= np.random.rand(1000= np.random.rand(1000*50= np.random.rand(1000# 散点图#颜色栏plt.show()
 ![](http://images2017.cnblogs.com/blog/151822/201801/151822-20180113001655894-342726755.png)
ImportMatplotlib.pyplot asPltImportNumPy asNp fromMpl_toolkits.mplot3dImportAxes3Dnp.random.seed ( the)# Number of samplesN_samples=  -Dim= 3Mr. # into a group of 3-D normal distribution data, the data direction is completely randomSamples=Np.random.multivariate_normal (Np.zeros (Dim), Np.eye (Dim), N_samples)# by matching each sample to the origin and the uniform distribution of the sample evenly distributed in the ball body. forIinch Range(samples.shape[0]): R=Np.power (Np.random.random (),1.0/3.0) Samples[i]*=R/Np.linalg.norm (Samples[i]) upper_samples=[]lower_samples=[] forX, Y, ZinchSamples# 3x+2y-z=1 as a discriminant plane    ifZ> 3*X+ 2*Y- 1: Upper_samples.append ((x, Y, z))Else: Lower_samples.append ((x, Y, z)) FIG=Plt.figure (' 3D scatter plot ') Ax=Fig.add_subplot (111, projection=' 3d ') Uppers=Np.array (upper_samples) lowers=Np.array (Lower_samples)# Use icons of different colors and shapes to represent the samples on the plane# discriminant The upper half of the plane is the red dot, the lower half is the green triangleAx.scatter (uppers[:,0], uppers[:,1], uppers[:,2], C=' R ', marker=' O ') Ax.scatter (lowers[:,0], lowers[:,1], lowers[:,2], C=' G ', marker='^') Plt.show ()# Reference https://zhuanlan.zhihu.com/p/24309547

Using the pandas data input and output library

Reference http://python.jobbole.com/80853/

ImportPandas asPD DF=Pd. DataFrame ({' A ':1.,' B ': PD. Timestamp (' 20130102 '),' C ': PD. Series (1, index=List(Range(4)), Dtype=' float32 '),' D ': PD. Series ([1,2,1,2], Dtype=' Int32 '),' E ': PD. Categorical (["Test","Train","Test","Train"]),' F ':' foo '}) DF
A B C D E F
0 1.0 2013-01-02 1.0 1 Test Foo
1 1.0 2013-01-02 1.0 2 Train Foo
2 1.0 2013-01-02 1.0 1 Test Foo
3 1.0 2013-01-02 1.0 2 Train Foo
df.B
0   2013-01-021   2013-01-022   2013-01-023   2013-01-02Name: B, dtype: datetime64[ns]
Using the Seaborn Drawing library

Seaborn essentially uses matplotlib as the core library, creating visually pleasing graphs by default

# http://python.jobbole.com/80853/importas# Load one of the data sets that come with seaborn= sns.load_dataset("tips") sns.jointplot("total_bill""tip", tips, kind='reg');

tips.head()
Day Time
Total_bill Tip Sex Smoker size
0 16.99 1.01 Female No Sun D Inner 2
1 10.34 1.66 Male No Sun Dinner 3
2 21.01 3.50 Male No Sun Dinner 3
3 23.68 3.31 Male No Sun Dinner 2
4 24.59 3.61 Female No sun Dinner 4
sns.lmplot("total_bill""tip", tips, col="smoker");

Other references

http://blog.csdn.net/qq_34264472/article/details/53814653

Https://www.cnblogs.com/kylinlin/p/5236601.html

http://blog.csdn.net/u013082989/article/details/73278458

Https://www.cnblogs.com/gczr/p/6767175.html

Python Jupyter notebook various use methods record

http://blog.csdn.net/tina_ttl/article/details/51031113

Jupyter changing Themes

Https://github.com/dunovank/jupyter-themes

Installation topics

    1. Pip Install Jupyterthemes

If Unicodedecodeerror: ' GBK ' Chinese issue, can install the previous version
Pip Install jupyterthemes==0.18.3

View installed with themes

    1. Command line Jt-l

Apply Theme

    1. Command line jt-t onedork-f fira-fs 13

-fs 13 Fonts

Reply to original state

    1. Jt-r
# 嵌入视频fromimport VimeoVideoVimeoVideo("63250251",with=600, height=400)
  File "<ipython-input-21-5e0fd48278da>", line 3    VimeoVideo("63250251",with=600, height=400)                             ^SyntaxError: invalid syntax
# 交互图表import ipywidgetsa=ipywidgets.IntSlider(value=5,min=0max=10, step=1)a
ipywidgets.Text()
# 嵌入HTML页面fromimport HTMLHTML('<iframe src="https://www.baidu.com" width=800 height=400></iframe>')
# 运行外部.py程序#    %run xxxx/xxxx.py
# Geo-Json
Installing the Jupyter Lab Python IDE
    1. Pip Install Jupyterlab

Execute Jupyter Lab

Yangtao's Python/jupyter study notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.