Skip to content

Writing CSV to disk hangs if the DataFrame is large-ish with a string (object) index (no errors in logs, not out of memory) #4990

Closed

Description

@bsesar

What happened:
Dask hangs when writing a large DataFrame to the disk in CSV format.

What you expected to happen:
The DataFrame should have been saved to the disk.

Minimal Complete Verifiable Example:

import multiprocessing.popen_spawn_win32
from dask.distributed import Client
import dask.dataframe as dd
import pandas as pd
from shutil import rmtree
import numpy as np

client = Client()

# create two DataFrames, one with a string index and one without it
Nrows = 83345093
df = pd.DataFrame(np.random.randn(Nrows, 2), columns=list('AB'), index=pd.util.testing.rands_array(16, Nrows, dtype='O'))
df2 = pd.DataFrame(np.random.randn(Nrows, 2), columns=list('AB'))

# create two Dask DataFrames
ddf = dd.from_pandas(df, npartitions=240)
ddf2 = dd.from_pandas(df2, npartitions=240)

# dump the DataFrame without the string index (this works)
ddf2.to_csv('output')
rmtree('output')
ddf2.to_csv('output')
rmtree('output')

# dump the DataFrame with the string index, but one partition at a time (this works)
for partition_id in range(240):
   print(partition_id)
   ax = ddf.get_partition(partition_id)
   _ = ax.to_csv('output')
   rmtree('output')

# dump the DataFrame with the string index, all partitions (this hangs at some point)
ddf.to_csv('output')
rmtree('output')
ddf.to_csv('output')
rmtree('output')

Anything else we need to know?:

Environment:

  • Dask version: 2021.6.2
  • Numpy version: 1.20.3
  • Pandas version: 1.2.5
  • Python version: 3.9.4
  • Operating System: Windows Server 2016 64 bits
  • Install method (conda, pip, source): conda

Activity

  1. changed the title [-]Writing CSV to disk hangs if the DataFrame is large with a string (object) index[/-] [+]Writing CSV to disk hangs if the DataFrame is large-ish with a string (object) index (no errors in logs, not out of memory)[/+] on Jun 30, 2021
  2. jrbourbeau commented on Jun 30, 2021

    @jrbourbeau
    Member

    Closing to avoid duplicates issues (xref dask/dask#7848)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions