A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/7885 below:

using pd.Grouper with a multi-level index and specifying level (and freq) buggy · Issue #7885 · pandas-dev/pandas · GitHub

Skip to content Navigation Menu

Saved searches Use saved searches to filter your results more quickly

Sign up 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 Additional navigation options

BUG: using pd.Grouper with a multi-level index and specifying level (and freq) buggy #7885

Description

http://stackoverflow.com/questions/25050015/resampling-over-dates-in-both-levels-of-a-multiindex-pandas-dataframe/25050074#25050074

from datetime import date
d0 = date.today() - timedelta(days=14)
dates = pd.date_range(d0, date.today())
date_index = pd.MultiIndex.from_product([dates, dates], names=['cohort_date', 'event_date'])
df = pd.DataFrame(np.random.randint(0, 100, 225), index=date_index)

Works

df.reset_index().groupby([pd.Grouper(key='cohort_date',freq='W'),pd.Grouper(key='event_date',freq='W')]).sum()

This should be equivalent, but raises

df.groupby([pd.Grouper(level='cohort_date',freq='W'),pd.Grouper(level='event_date',freq='W')]).sum()

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4