Skip to content

how to get info (total memory usage) of a dask.dataframe? #8115

Closed

Description

@raybellwaves

I'm hoping to get an idea of the memory size of a dask.dataframe once I call .compute() on it

My current approach is

import dask.dataframe as dd
from dask.utils import format_bytes

ddf = dd.demo.make_timeseries(
    start="2000-01-01",
    end="2000-01-02",
    dtypes={"x": float, "y": float, "id": int},
    freq="10ms",
    partition_freq="24h",
)

format_bytes(ddf.memory_usage(deep=True).sum().compute())

Screen Shot 2021-09-02 at 4 53 39 PM

pandas has .info which gives the this as well as other info (and returns a NoneType)

I see dask.dataframe has an info() method but not sure if it works as expected:

ddf.info()

Screen Shot 2021-09-02 at 4 57 01 PM

ddf.info.compute()
AttributeError: 'NoneType' object has no attribute 'compute'

Activity

  1. jrbourbeau commented on Sep 2, 2021

    @jrbourbeau
    Member

    Thanks for reporting @raybellwaves, I'm able to reproduce. It looks like if I pass verbose=True, then the Dask result is what I would expect based on the pandas .info() method:

    In [15]: df.info(verbose=True)
    <class 'dask.dataframe.core.DataFrame'>
    DatetimeIndex: 2592000 entries, 2000-01-01 00:00:00 to 2000-01-30 23:59:59
    Data columns (total 4 columns):
     #   Column  Non-Null Count  Dtype
    ---  ------  --------------  -----
     0   id      2592000 non-null      int64
     1   name    2592000 non-null      object
     2   x       2592000 non-null      float64
     3   y       2592000 non-null      float64
    dtypes: object(1), float64(2), int64(1)
  2. jsignell commented on Sep 7, 2021

    @jsignell
    Member

    So it seems like the task here is:

    1. add the total memory usage to the output of info(verbose=True)
    2. change the default from verbose=False to verbose=True

    1 seems like a good and straightforward addition to me, but 2 is a little more controversial since flipping the kwarg would trigger computation everytime info is called, which is obviously something that dask tries to avoid.

  3. added
    good first issue
    on Sep 16, 2021
  4. chirag-indi commented on Sep 18, 2021

    @chirag-indi

    Hi,
    I'm a little new to Open Source. Could I take this up?

  5. jsignell commented on Sep 20, 2021

    @jsignell
    Member

    Sure! The work is to add the total_memory usage to the output of info when verbose=True. Just let me know if you run into any issues :)

  6. chirag-indi commented on Sep 20, 2021

    @chirag-indi

    Hi Julia! (@jsignell)

    It was a pretty small change as most of it was already present. I was able to get it working but had a couple of small questions before I opened up a PR.

    The enhancement to ddf.info(verbose=True)
    image

    1. Considering the problem faced by @raybellwaves, wouldn't another already implement approach be using ddf.info(memory_usage=True)?
      image

    2. Would you also suggest that I change the default from verbose=False to verbose=True, as stated in the older content?

    Thank you!

  7. jsignell commented on Sep 20, 2021

    @jsignell
    Member

    Yeah you are right! I should have gone to look at the method to check on what kwargs were already there. Given that there is already a memory_usage=True kwarg, I think we can either just close this issue, or we could make verbose=True also set memory_usage=True.

    For 2. I do not think we should flip the default from verbose=False to verbose=True. My thinking is that anytime dask triggers computation without the user explicitly calling compute() it is potentially surprising.

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

    dataframegood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions