来源:麦叔编程
作者:麦叔
本文帮你快速掌握数据分析师必须会用的两个工具 - ipython和jupyter notebook。
既然有了Python,为什么还要ipython?麦叔不用说话,给你一张图你就明白啦。jupyter notebook又是什么鬼?
建议把本文放到收藏夹。吃灰也好过需要的时候找不到。
iPython是Interactive Python,它是基于Python的一个包装。它其实就是一个可以通过pip安装的包。提供了普通python之外的一些功能,其中一个功能就是可以显示图片。
iPython在数据分析师,数据科学家,人工智能科学中经常使用。
(1)安装
python -m pip install ipython
(2)使用
ipython就是Python,使用方法和使用普通的交互式Python一样,代码也一样。只不过输出显示上有一定优化。
zjueman@maishu data_analysis % ipython Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019,
14:08:53) Type 'copyright', 'credits' or 'license' for more information IPython
7.21.0 -- An enhanced Interactive Python. Type '?' for help. In [1]:
2.使用ipython:为了运行一下代码,请先安装numpy:
python -m pip install numpy
In [1]: a = 5 In [2]: b = "麦叔" In [3]: import numpy as np In [4]:
data = {i:np.random.randn() for i in range(7)} In [5]: data Out[5]: {0: 0.8738401705018338,
1: 0.7173530856483666, 2: 1.269301701227684, 3: -0.6322949353286054, 4: -2.3619895093818295,
5: -0.9031446928993554, 6: -0.07942775508126601}
3.问号寻求帮助:
In [4]: name = 'maishu' In [5]: name?
Type: str
String form: maishu
Length: 6 Docstring:
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.__str__() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to 'strict'.
4.退出
In [10]: quit() zjueman@maishu data_analysis %
5.画图 为了运行一下代码需要先安装matplotlib
python -m pip install matplotlib
In [1]: import numpy as np In [2]: %matplotlib Using matplotlib backend: MacOSX In [3]: import matplotlib.pyplot as plt In [4]: plt.plot(np.random.randn(50).cumsum()) Out[4]: [<matplotlib.lines.line2d at 0x7fa7e7f8ce20>]matplotlib.lines.line2d at 0x7fa7e7f8ce20>
数据科学家们觉得ipython还不够过瘾,又在ipython基础上开发了jupyter notebook:一个基于网页的写代码界面。
jupyter是基于ipython的,很多操作几乎都一样。但是它有很多独特优点:
(1)文件可以保存为ipynb的文件
(2)在线编写代码
(3)支持多人协作
(4)支持markdown格式的文档
1. 安装
python -m pip install jupyter
2. 启动
> jupyter notebook
这个命令会在本机的8888端口上运行一个网站,并自动打开浏览器:
http://localhost:8888/tree
3. 基本使用
(1)创建文件
(2)编写和运行代码
(3)保存和修改文件名
4. Tab补全
在notebook中打代码的过程中,按Tab键可以自动提示和补全,类似于Pycharm和VSCode等IDE的功能:
它可支持:
(1)自动补全变量名
(2)自动补全函数名
(3)自动补全文件名等
5. 集成matplotlib画图
6. 魔术命令
(1)运行脚本:%run
(2)打印命令输入历史:%hist
(3)运行效率:%timeit
(4)其他魔术命令
(1)停止执行:Ctrl+C
(2)其他ipython快捷键
数据分析咨询请扫描二维码
数据挖掘是现代企业利用数据驱动决策的重要工具。它涉及从大量数据中提取隐藏的、先前未知但潜在有用的信息,依托人工智能、机器 ...
2024-10-23在当前数据驱动的商业环境中,数据分析师的角色变得越来越重要。想要踏入这一领域并取得成功,不仅需要扎实的技术基础,还需要不 ...
2024-10-23数据分析是一个广泛而又精细的领域,它结合了统计学、计算机科学、商业策略以及数据科学等多个学科的知识。这个领域日新月异的发 ...
2024-10-23在现代企业中,数字化管理师扮演着至关重要的角色。他们不仅帮助企业优化资源配置,还推动企业的数字化转型。要成为一名合格的数 ...
2024-10-23大数据专业是一个跨学科的领域,涵盖了数学、统计学、计算机科学与技术等多个学科。随着数据在各个行业中的重要性日益增加,大数 ...
2024-10-23大数据分析师培训教程-2.1 Hadoop入门-Hadoop 1.0 的局限与 Hadoop 2.0(YARN)的革新 Hadoop简介Hadoop 的生态系统HDFS 的原理 ...
2024-10-232024,您是否渴望在数据领域探索更广阔的职业机遇? 数字化时代,数据量级每年都在呈指数级增长。据统计,全球互联网用户每天产 ...
2024-10-21数据科学专业是一门跨学科的综合性学科,涵盖了数学、统计学、计算机科学等多个领域。其核心目标是通过数据的收集、处理和分析来 ...
2024-10-21Python是一种高级解释性编程语言,由Guido van Rossum于1991年创造。凭借其简单易学、代码可读性强和功能强大的特点,Python已经 ...
2024-10-21在当今数据驱动的世界中,选择学习Hadoop已成为许多数据分析师和IT专业人士的必修课。Hadoop不仅是大数据处理领域的核心技术之一 ...
2024-10-21数据开发工程师在当今数据驱动的世界中扮演着至关重要的角色。他们不仅负责数据的采集和处理,还在数据仓库建设、系统开发和数据 ...
2024-10-20在当今快速变化的数字经济时代,数字化转型已经成为企业实现持续增长和竞争优势的关键。数字化转型不仅仅是技术的变革,更是组织 ...
2024-10-19在当今快速发展的科技时代,数字经济已成为全球经济的重要组成部分。选择数字经济专业,不仅能为你打开通往多个行业的大门,还能 ...
2024-10-18学习统计学与大数据分析具有显著的优势,能够帮助你走向高薪岗位。在数字化时代背景下,统计学和大数据分析展现出强大的就业潜力 ...
2024-10-18在当今的数字时代,数据科学与大数据技术专业的就业方向极为广泛,涵盖了多个领域和岗位。随着数据成为企业决策的重要依据,行业 ...
2024-10-18大数据技术与应用领域正在迅速发展,成为现代经济和科技发展的重要驱动力。随着数据量的爆炸式增长,各行各业对大数据专业人才的 ...
2024-10-18在当今数据驱动的商业环境中,数据分析软件已成为企业决策过程中不可或缺的工具。随着数据量的激增和分析需求的复杂化,选择合适 ...
2024-10-18在当今数据驱动的世界中,数据分析已成为许多行业不可或缺的一部分。无论是企业决策、市场营销,还是产品开发,数据分析都能提 ...
2024-10-18数据分析在现代企业中扮演着至关重要的角色,帮助企业在竞争激烈的市场中做出明智的决策。随着数据量的不断增长,企业需要依赖先 ...
2024-10-18CDA(Certified Data Analyst)认证在数据分析领域具有显著的作用,具体包括以下几个方面: 1. 专业技能认可 CDA认证是数据分析 ...
2024-10-17