dask

How to run dask in multiple machines? [closed]

柔情痞子 提交于 2020-05-28 03:28:18
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I found Dask recently. I have very basic questions about Dask Dataframe and other data structures. Is Dask Dataframe immutable data type? Is Dask array and Dataframe are lazy data structure? I dont know whether to use dask or spark or pandas for my situation. I have 200 GB of data

Remove empty partitions in Dask

这一生的挚爱 提交于 2020-05-27 10:33:51
问题 When loading data from CSV some CSVs cannot be loaded, resulting in an empty partition. I would like to remove all empty partitions, as some methods seem to not work well with empty partitions. I have tried to repartition, where (for example) repartition(npartitions=10) works, but a value greater than this can still result in empty partitions. What's the best way of achieving this? Thanks. 回答1: I've found that filtering a Dask dataframe, e.g., by date, often results in empty partitions. If

Dask read_csv— Mismatched dtypes found in `pd.read_csv`/`pd.read_table`

百般思念 提交于 2020-05-27 04:38:06
问题 I'm trying to use dask to read csv file, and it gave me an error like below. But the thing is I want my ARTICLE_ID be object(string) . Anyone can help me to read data successfully? Traceback is like below: ValueError: Mismatched dtypes found in `pd.read_csv`/`pd.read_table`. +------------+--------+----------+ | Column | Found | Expected | +------------+--------+----------+ | ARTICLE_ID | object | int64 | +------------+--------+----------+ The following columns also raised exceptions on

dask apply: AttributeError: 'DataFrame' object has no attribute 'name'

强颜欢笑 提交于 2020-05-27 03:13:10
问题 I have a dataframe of params and apply a function to each row. this function is essentially a couple of sql_queries and simple calculations on the result. I am trying to leverage Dask's multiprocessing while keeping structure and ~ interface. The example below works and indeed has a significant boost: def get_metrics(row): record = {'areaName': row['name'], 'areaType': row.area_type, 'borough': row.Borough, 'fullDate': row['start'], 'yearMonth': row['start'], } Q = Qsi.format(unittypes=At,

Reading CSV files from Google Cloud Storage using pandas

一个人想着一个人 提交于 2020-05-23 11:40:08
问题 I am trying to read a bunch of CSV files from Google Cloud Storage into pandas dataframes as explained in Read csv from Google Cloud storage to pandas dataframe storage_client = storage.Client() bucket = storage_client.bucket(bucket_name) blobs = bucket.list_blobs(prefix=prefix) list_temp_raw = [] for file in blobs: filename = file.name temp = pd.read_csv('gs://'+bucket_name+'/'+filename+'.csv', encoding='utf-8') list_temp_raw.append(temp) df = pd.concat(list_temp_raw) It shows the following

How to scale operations with a massive dictionary of lists in Python?

寵の児 提交于 2020-05-15 08:12:10
问题 I'm dealing with a "big data" problem in python, and I am really struggling for scalable solutions. The data structure I currently have is a massive dictionary of lists, with millions of keys and lists with millions of items. I need to do an operation on the items in the list. The problem is two-fold: (1) How to do scalable operations on a data structure this size? (2) How to do this with constraints of memory? For some code, here's a very basic example of a dictionary of lists: example_dict1

Sampling n= 2000 from a Dask Dataframe of len 18000 generates error Cannot take a larger sample than population when 'replace=False'

橙三吉。 提交于 2020-05-14 18:15:08
问题 I have a dask dataframe created from a csv file and len(daskdf) returns 18000 but when I ddSample = daskdf.sample(2000) I get the error ValueError: Cannot take a larger sample than population when 'replace=False' Can I sample without replacement if the dataframe is larger than the sample size? 回答1: The sample method only supports the frac= keyword argument. See the API documentation The error that you're getting is from Pandas, not Dask. In [1]: import pandas as pd In [2]: df = pd.DataFrame({

Sampling n= 2000 from a Dask Dataframe of len 18000 generates error Cannot take a larger sample than population when 'replace=False'

橙三吉。 提交于 2020-05-14 18:15:04
问题 I have a dask dataframe created from a csv file and len(daskdf) returns 18000 but when I ddSample = daskdf.sample(2000) I get the error ValueError: Cannot take a larger sample than population when 'replace=False' Can I sample without replacement if the dataframe is larger than the sample size? 回答1: The sample method only supports the frac= keyword argument. See the API documentation The error that you're getting is from Pandas, not Dask. In [1]: import pandas as pd In [2]: df = pd.DataFrame({

5分钟入门pandas

泄露秘密 提交于 2020-05-07 13:26:31
pandas是在数据处理、数据分析以及数据可视化上都有比较多的应用,这篇文章就来介绍一下pandas的入门。劳动节必须得劳动劳动 1. 基础用法 以下代码在 jupyter 中运行,Python 版本3.6。首先导入 pandas import pandas as pd # 为了能在jupyter中展示图表 %matplotlib inline 复制代码 # 从csv文件读取数据,也可从excel、json文件中读取 # 也可以通过sql从数据库读数据 data = pd.read_csv( 'order_list.csv' ) 复制代码 # 输出几行几列 data.shape output: ( 1000 , 3 ) 复制代码 可以看到,变量 data 是一个二维表,有1000行,3列。pandas中这种数据类型被称作 DataFrame。 # 查看数据描述 data.describe() 复制代码 data 中有3列,good_id、good_cnt 和 order_id 分别代表商品id、购买该商品数量和订单id。最左侧是 describe 函数统计的指标,包括每一列的数量、均值、标准差、最大值、最小值等等。 # 预览数据,条数可设 data.head( 3 ) 复制代码 # 获取第2行数据 data.loc[ 2 ] output: good_id 100042 good

5分钟入门pandas

拟墨画扇 提交于 2020-05-05 16:10:19
pandas是在数据处理、数据分析以及数据可视化上都有比较多的应用,这篇文章就来介绍一下pandas的入门。劳动节必须得劳动劳动 1. 基础用法 以下代码在 jupyter 中运行,Python 版本3.6。首先导入 pandas import pandas as pd # 为了能在jupyter中展示图表 %matplotlib inline # 从csv文件读取数据,也可从excel、json文件中读取 # 也可以通过sql从数据库读数据 data = pd.read_csv( 'order_list.csv' ) # 输出几行几列 data.shape output: ( 1000 , 3 ) 可以看到,变量 data 是一个二维表,有1000行,3列。pandas中这种数据类型被称作 DataFrame。 # 查看数据描述 data.describe() data 中有3列,good_id、good_cnt 和 order_id 分别代表商品id、购买该商品数量和订单id。最左侧是 describe 函数统计的指标,包括每一列的数量、均值、标准差、最大值、最小值等等。 # 预览数据,条数可设 data.head( 3 ) # 获取第2行数据 data.loc[ 2 ] output: good_id 100042 good_cnt 1 order_id 10000002