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
data = pd.read_parquet('./data.pq', engine='fastparquet', filters=[('day', 'in', [26,28])], index='index')
c = data.groupby('day')['time'].apply(lambda x : x.diff(1).dt.total_seconds().fillna(0))
Yield a series with index matching the initial dataframe
now with dask:
import dask.dataframe as dd
data = dd.read_parquet('./data.pq', engine='fastparquet', filters=[('day', 'in', [26,28])], index='index')
c = data.groupby('day')['time'].apply(lambda x : x.diff(1).dt.total_seconds().fillna(0), meta=pd.Series(dtype='uint8', name='diff')).compute()
yields a series with name=diff, dtype='float64' and indexes that don't match the initial data, neither range(0,n)... There is an argument 'index' in the meta pd.series but what I tried didn't give me the initial data indexes. The values are the same as before (with pandas), only index differs.
This is a problem because I am unable to do something like this
I am having the same issue. It seems that using meta keywoard in apply of a grouped dataframe results in a false index in the _meta property of the dataframe, e.g
It seems that using meta keywoard in apply of a grouped dataframe results in a false index in the _meta property of the dataframe, e.g
Dask accepts things like meta=('samples', np.dtype('O')) as a shorthand for pd.Series(name='samples', dtype=object), which ash a RangeIndex. If you need the MultiIndex you'll need to specify that.
Activity
avlahop commentedon Apr 2, 2018
I am having the same issue. It seems that using
metakeywoard in apply of a grouped dataframe results in a false index in the_metaproperty of the dataframe, e.gAlternatively not using meta:
fl2o commentedon Apr 5, 2018
update:
Trying to compute intermediate results (with and w/o metadata) gives an error because of the indexes.
diff.compute() yields "ValueError: cannot reindex from a duplicate axis"
looking at the indexes of data:
TomAugspurger commentedon Aug 8, 2019
@FL20 DataFrameGroupBy.apply applies the user-provided function to each partition: https://docs.dask.org/en/latest/dataframe-api.html#dask.dataframe.groupby.DataFrameGroupBy.apply explains that better now I hope.
Dask accepts things like
meta=('samples', np.dtype('O'))as a shorthand forpd.Series(name='samples', dtype=object), which ash a RangeIndex. If you need the MultiIndex you'll need to specify that.Let me know if I missed anything.