Python中的Dask数组
Python Dask數組 (Python Dask Array)
Dask is parallel computing python library and it is mainly used to run across multiple systems. Dask is used to process the data efficiently on a different cluster of machines. Dask can completely use all the cores available in the machine.
Dask是并行計算的python庫,主要用于跨多個系統運行。 Dask用于在其他計算機群集上有效地處理數據。 Dask可以完全使用機器中可用的所有內核。
Dask stores the complete data on the disk and uses chunks of data from the disk for processing. Dask analyzes the large data sets with the help of Pandas data frame and "numpy arrays".
Dask將完整的數據存儲在磁盤上,并使用磁盤中的數據塊進行處理。 Dask借助Pandas數據框和“ numpy數組” 來分析大型數據集。
Basically, dask arrays are distributed "numpy arrays". A large "numpy array" is divided into smaller arrays and they are grouped together to form dask array.
基本上, dask數組是分布式的“ numpy數組”。 大的“ numpy數組”分為較小的數組,它們組合在一起形成dask數組 。
Install using this command:
使用以下命令進行安裝:
pip install daskDask array.asarray is used to convert the given input into dask array. It converts lists, tuples, numpy array to dask array.
Dask array.asarray用于將給定的輸入轉換為dask array 。 它將列表,元組,numpy數組轉換為dask數組 。
Program to create a dask array:
程序創建一個dask數組:
Example #1:
范例1:
import dask.array as p rk = [1,2,3,4,5] #converts the list into dask array d=p.asarray(rk) print(d.compute()) #print type of d print(type(d)) r = (1,2,3) #converts the tuple into dask array k=p.asarray(r) print(k.compute()) #print type of k print(type(k))Output
輸出量
[1 2 3 4 5] <class 'dask.array.core.Array'> [1 2 3] <class 'dask.array.core.Array'>Example #2:
范例2:
import dask.array as p import numpy as np #create a numpy array r=np.arange(5) print(r) #print type of numpy array print(type(r)) #converting numpy array to dask array d=p.asarray(r) print(d.compute()) print(type(d)) t=np.array([1,2,3]) print(t) #print type of numpy array print(type(t)) #converting numpy array to dask array f=p.asarray(t) print(f.compute()) #print type of dask array print(type(f))Output
輸出量
[0 1 2 3 4] <class 'numpy.ndarray'> [0 1 2 3 4] <class 'dask.array.core.Array'> [1 2 3] <class 'numpy.ndarray'> [1 2 3] <class 'dask.array.core.Array'>翻譯自: https://www.includehelp.com/python/dask-array.aspx
總結
以上是生活随笔為你收集整理的Python中的Dask数组的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 最常见的10种Java异常问题!
- 下一篇: 软件工程质量管理体系要求_软件质量管理|