python - Turning DataFrameGroupBy.resample hierarchical index into columns -


i have dataset contains individual observations need aggregate @ coarse time intervals, function of several indicator variables @ each time interval. assumed solution here groupby operation, followed resample:

adult_resampled = adult_data.set_index('culture', drop=false).groupby(['over64','regioneast','pneumo7',             'pneumo13','pneumo23','pneumononpcv','penr','levr',             'erythr','pens','levs','eryths'])['culture'].resample('as', how='count') 

the result awkward-looking series massive hierarchical index, perhaps not right approach, need turn hierarchical index columns. way can hack hierarchical index (by pulling out index labels, contents of columns need).

hack

any tips on ought have done instead appreciated!

i've tried new grouper syntax, not allow me subsequently change hierarchical indices data columns. applying unstack table:

grouper

results in this:

bad unstack

in order dataset useful, in regression model, need index labels indicators in columns.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -