数据分析

部署环境

(base) $ conda config --add channels conda-forge
(base) $ conda config --set channel_priority strict

(base) $ conda create -y -n pydata-book python=3.10
(base) $ conda activate pydata-book    //进入pydata-book

安装依赖

题外:尽量全部使用conda安装,不成功再用pip

(pydata-book) $ conda install -y pandas jupyter matplotlib

conda install lxml beautifulsoup4 html5lib openpyxl requests sqlalchemy seaborn scipy statsmodels patsy scikit-learn pyarrow pytables numba

IPython

(pydata-book) ipython

In [1]: a = 5

In [2]: a
Out[2]: 5

In [3]: import numpy as np

In [4]: data = [np.random.standard_normal() for i in range(7)]

In [5]: data
Out[5]: 
[-0.20470765948471295,
 0.47894333805754824,
 -0.5194387150567381,
 -0.55573030434749,
 1.9657805725027142,
 1.3934058329729904,
 0.09290787674371767]

Jupyter Notebook

(pydata-book) Jupyter Notebook

image-20230415012644596

image-20230415012658168

image-20230423194432488

  • 重命名:单击页面顶部的笔记本标题并键入新标题,完成后按 Enter

数据结构

  • 元组:元素不能随意更改

    • 字符串转元祖

      tup = tuple('string')
      
    • 变量拆包:

      In [34]: values = 1, 2, 3, 4, 5
      
      In [35]: a, b, *rest = values
      
      In [36]: a
      Out[36]: 1
      
      In [37]: b
      Out[37]: 2
      
      In [38]: rest
      Out[38]: [3, 4, 5]
      
  • 列表

    • append
    • insert
    • pop
    • sort
    • 切片
  • 字典

    • del
    • pop
    • update
  • 集合

python基础

  • 匿名 (Lambda) 函数

    • equiv_anon = lambda x: x * 2
      
    • In [201]: def apply_to_list(some_list, f):
         .....:     return [f(x) for x in some_list]
      
      In [202]: ints = [4, 0, 1, 5, 6]
      
      In [203]: apply_to_list(ints, lambda x: x * 2)
      Out[203]: [8, 0, 2, 10, 12]
      
  • 打开文件

    • In [233]: path = "examples/segismundo.txt"
      
      In [234]: f = open(path, encoding="utf-8")
      
    • In [237]: f.close()
      

pytorch

发展

  • Theano
    • TensorFlow
    • TensorFloweager
  • Torch7
    • pytorch+THNN
    • pytorch+Caffe2
  • Caffe
    • Caffe2
    • Pytorch1.0

image-20230414000644207


文章作者: 寜笙
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 寜笙 !
 上一篇
2023-04-15 寜笙
下一篇 
2023-04-08 寜笙
  目录