You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Groupby-agg on index with known divisions results in unknown divisions #2999
I would expect ddf.groupby(ddf.index).sum() to have same divisions as ddf, but they seem to be unknown. Not sure if this is a desired behaviour or if I'm doing something wrong.
Right, I think that groupby-aggregations currently always produce a
single-partition dataframe. There isn't currently any special behavior
when operating on the index.
We do perform special behavior on groupby-apply operations, just because
not doing special behavior here can be so much more expensive (full
shuffles occur).
It seems reasonable to me to also add special handling on
groupby-aggregations as you suggest if we happen to have well-known
divisions (as we do in your case).
On Fri, Dec 15, 2017 at 3:29 AM, Michał D ***@***.***> wrote:
After taking a look at dask tests I discovered what follows:
In[2]: import dask
...: import dask.dataframe as dd
...: import pandas as pd
...: import numpy as np
In[3]: ddf = dd.from_pandas(pd.DataFrame({'A': [1, 2]}, index=pd.Series([0, 1], name='idx')), npartitions=1)
In[4]: ddf.divisions
Out[4]: (0, 1)
In[5]: ddf.groupby(ddf.index).sum().divisions
Out[5]: (None, None)
In[6]: ddf.groupby('idx').sum().divisions
Out[6]: (None, None)
In[7]: ddf.groupby(ddf.index).apply(np.sum).divisionsUserWarning: `meta` is not specified...
Out[7]: (None, None)
In[8]: ddf.groupby('idx').apply(np.sum).divisionsUserWarning: `meta` is not specified...
Out[8]: (0, 1)
(warnings were truncated)
So, the expected behaviour occurs only when
1. I pass index name instead of the index itself to a groupby method
AND
2. I use .apply(np.sum) instead of .sum() as an aggregation (works
with built-in sum too)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2999 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AASszGy9RCDB2iZ8hyje6BHJGK7hDCQKks5tAjvogaJpZM4RCTnZ>
.
Activity
michcio1234 commentedon Dec 15, 2017
After taking a look at dask tests I discovered what follows:
(warnings were truncated)
So, the expected behaviour occurs only when
groupbymethod AND.apply(np.sum)instead of.sum()as an aggregation (works with built-insumtoo)mrocklin commentedon Dec 16, 2017