Skip to content

BUG: df.pivot_table: margins_name is ignored when there aggfunc is list #13354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ekeydar opened this issue Jun 3, 2016 · 1 comment
Closed
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@ekeydar
Copy link

ekeydar commented Jun 3, 2016

Code Sample, a copy-pastable example if possible

costs = pd.DataFrame({'item':['bacon','cheese','bacon','cheese'],
                      'cost':[2.5,4.5,3.2,3.3],
                     'store':['SuperS','DollarM','SuperS','DollarM'],
                     'day':['M','M','T','T']})
costs.pivot_table(index="item",columns="day",margins=True, margins_name="Weekly",aggfunc=[np.mean,max])

Will ignore the margins_name

Expected Output

      mean               max                                     
       cost              cost              store                  
          M     T    Weekly    M    T  Weekly        M        T      Weekly
item                                                              
bacon   2.5  3.20  2.850  2.5  3.2  3.2   SuperS   SuperS   SuperS
cheese  4.5  3.30  3.900  4.5  3.3  4.5  DollarM  DollarM  DollarM
All     3.5  3.25  3.375  4.5  3.3  4.5   SuperS   SuperS   SuperS

output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.4.3.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-43-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.18.1
nose: None
pip: 1.5.6
setuptools: 20.2.2
Cython: None
numpy: 1.11.0
scipy: 0.17.1
statsmodels: None
xarray: None
IPython: 4.1.2
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.3
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
httplib2: 0.9.2
apiclient: 1.5.0
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None
@ekeydar ekeydar changed the title margins df.pivote_table: margins_name is ignored when there are aggfuncs Jun 3, 2016
@ekeydar ekeydar changed the title df.pivote_table: margins_name is ignored when there are aggfuncs df.pivote_table: margins_name is ignored when there aggfunc is list Jun 3, 2016
@jreback
Copy link
Contributor

jreback commented Jun 3, 2016

yep, looks like this is not being passed thru here

pull-request welcomed!

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode Difficulty Novice labels Jun 3, 2016
@jreback jreback added this to the Next Major Release milestone Jun 3, 2016
@jreback jreback changed the title df.pivote_table: margins_name is ignored when there aggfunc is list BUG: df.pivot_table: margins_name is ignored when there aggfunc is list Jun 3, 2016
@jreback jreback modified the milestones: 0.18.2, Next Major Release Jun 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
2 participants