Anaconda是一个和Canopy类似的科学计算环境,但用起来更加方便。自带的包管理器conda也很强大。
首先是下载安装。Anaconda提供了Python2.7和Python3.4两个版本,同时如果需要其他版本,还可以通过conda来创建。安装完成后可以看到,Anaconda提供了Spyder,IPython和一个命令行。下面来看一下conda。
输入 conda list 来看一下所有安装时自带的Python扩展。粗略看了一下,其中包括了常用的 Numpy , Scipy , matplotlib 和 networkx 等,以及 beautiful-soup , requests , flask , tornado 等网络相关的扩展。
奇怪的是,里边竟然没有 sklearn ,所以首先装一下它。
conda install scikit-learn
如果需要指定版本,也可以直接用 [package-name]=x.x 来指定。
conda的repo中的扩展不算太新,如果想要更新的,可能要用PyPI或者自己下载源码。而conda和pip关联的很好。使用pip安装的东西可以使用conda来管理,这点要比Canopy好。下图是我用pip安装的 nltk , jieba 和 gensim 。
我对这个科学计算环境的另一个要求就是能够多个Python版本并存,尤其是2.x和3.x的并存。这个通过 virtualenv 可以做到。Anaconda也正是通过其实现的。
下面用conda创建一个名叫python2的版本为python2.7的环境。
conda create -n python2 python=2.7
这样就会在Anaconda安装目录下的envs目录下创建python2这个目录。
向其中安装扩展可以:
直接用 conda install 并用 -n 指明安装到的环境,这里自然就是 python2 。
像 virtualenv 那样,先activate,然后在虚拟环境中安装。
这里突然有一个问题,怎样在IDE中使用创建出来的环境?如果是PyCharm等IDE,直接设置Python安装目录就可以了。那spyder呢?其实spyder就是一个Python的扩展,你需要在虚拟环境中也装一个spyder。
最后就是spyder的主界面。变量查看窗口很好用。

SlicingaPythonlistisdoneusingthesyntaxlist[start:stop:step].Here'showitworks:1)Startistheindexofthefirstelementtoinclude.2)Stopistheindexofthefirstelementtoexclude.3)Stepistheincrementbetweenelements.It'susefulforextractingportionsoflistsandcanuseneg

NumPyallowsforvariousoperationsonarrays:1)Basicarithmeticlikeaddition,subtraction,multiplication,anddivision;2)Advancedoperationssuchasmatrixmultiplication;3)Element-wiseoperationswithoutexplicitloops;4)Arrayindexingandslicingfordatamanipulation;5)Ag

ArraysinPython,particularlythroughNumPyandPandas,areessentialfordataanalysis,offeringspeedandefficiency.1)NumPyarraysenableefficienthandlingoflargedatasetsandcomplexoperationslikemovingaverages.2)PandasextendsNumPy'scapabilitieswithDataFramesforstruc

ListsandNumPyarraysinPythonhavedifferentmemoryfootprints:listsaremoreflexiblebutlessmemory-efficient,whileNumPyarraysareoptimizedfornumericaldata.1)Listsstorereferencestoobjects,withoverheadaround64byteson64-bitsystems.2)NumPyarraysstoredatacontiguou

ToensurePythonscriptsbehavecorrectlyacrossdevelopment,staging,andproduction,usethesestrategies:1)Environmentvariablesforsimplesettings,2)Configurationfilesforcomplexsetups,and3)Dynamicloadingforadaptability.Eachmethodoffersuniquebenefitsandrequiresca

The basic syntax for Python list slicing is list[start:stop:step]. 1.start is the first element index included, 2.stop is the first element index excluded, and 3.step determines the step size between elements. Slices are not only used to extract data, but also to modify and invert lists.

Listsoutperformarraysin:1)dynamicsizingandfrequentinsertions/deletions,2)storingheterogeneousdata,and3)memoryefficiencyforsparsedata,butmayhaveslightperformancecostsincertainoperations.

ToconvertaPythonarraytoalist,usethelist()constructororageneratorexpression.1)Importthearraymoduleandcreateanarray.2)Uselist(arr)or[xforxinarr]toconvertittoalist,consideringperformanceandmemoryefficiencyforlargedatasets.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Zend Studio 13.0.1
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
