{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/10660","labels_url":"https://api.github.com/repos/pydata/pandas/issues/10660/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/10660/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/10660/events","html_url":"https://github.com/pydata/pandas/issues/10660","id":96765091,"number":10660,"title":".groupby().to_latex() output broken","user":{"login":"jakbaum","id":8722284,"avatar_url":"https://avatars.githubusercontent.com/u/8722284?v=3","gravatar_id":"","url":"https://api.github.com/users/jakbaum","html_url":"https://github.com/jakbaum","followers_url":"https://api.github.com/users/jakbaum/followers","following_url":"https://api.github.com/users/jakbaum/following{/other_user}","gists_url":"https://api.github.com/users/jakbaum/gists{/gist_id}","starred_url":"https://api.github.com/users/jakbaum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jakbaum/subscriptions","organizations_url":"https://api.github.com/users/jakbaum/orgs","repos_url":"https://api.github.com/users/jakbaum/repos","events_url":"https://api.github.com/users/jakbaum/events{/privacy}","received_events_url":"https://api.github.com/users/jakbaum/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pydata/pandas/labels/Output-Formatting","name":"Output-Formatting","color":"ededed"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-23T08:55:09Z","updated_at":"2015-07-23T10:00:02Z","closed_at":null,"body":"Hey folks,\r\n\r\nI posted this on [SO](https://stackoverflow.com/questions/31582114/groupby-to-latex-output-broken) and was asked to file a report here as well. \r\n\r\nI'm trying to export `pandas.DataFrame.describe()` to `LaTex` using the `to_latex()`-method. This works all fine as long as I don't apply the `groupby()`-method beforehand. With a grouped DataFrame, the first row has no values, even though its label is `count`. Note that the first row of a grouped dataframe is used to mark down the variable used for grouping in iPython notebook.\r\n\r\nI'm using pandas 0.16.2, python 3.\r\nIs this a bug or am I doing something wrong? \r\n\r\nCheers,\r\nJakob\r\n\r\nHere some examples:\r\n\r\nWithout `groupby`:\r\n\r\n    \\begin{tabular}{lr}\r\n    \\toprule\r\n    {} &    IS\\_FEMALE \\\\\r\n    \\midrule\r\n    count &  2267.000000 \\\\\r\n    mean  &     0.384649 \\\\\r\n    ...\r\n    ...\r\n    75\\%   &     1.000000 \\\\\r\n    max   &     1.000000 \\\\\r\n    \\bottomrule\r\n    \\end{tabular}\r\n\r\n\r\n[![enter image description here][1]][2]\r\n\r\nWith `groupby`:\r\n\r\n    \\begin{tabular}{llr}\r\n    \\toprule\r\n      &       &    IS\\_FEMALE \\\\\r\n    \\midrule\r\n    0 & count &              \\\\     % <-- note missing value here\r\n      & mean &  1134.000000 \\\\\r\n      & std &     0.554674 \\\\\r\n    ...\r\n    ...\r\n      & 75\\% &     0.000000 \\\\\r\n      & max &     0.000000 \\\\\r\n    \\bottomrule\r\n    \\end{tabular}\r\n\r\n[![enter image description here][3]][4]\r\n\r\nOutput in the notebook:\r\n\r\n[![enter image description here][5]][5]\r\n\r\n\r\n  [1]: http://i.stack.imgur.com/gK10V.png\r\n  [2]: http://i.stack.imgur.com/gK10V.png\r\n  [3]: http://i.stack.imgur.com/lt9z9.png\r\n  [4]: http://i.stack.imgur.com/lt9z9.png\r\n  [5]: http://i.stack.imgur.com/wT8Tp.png"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/124038497","html_url":"https://github.com/pydata/pandas/issues/10660#issuecomment-124038497","issue_url":"https://api.github.com/repos/pydata/pandas/issues/10660","id":124038497,"user":{"login":"jorisvandenbossche","id":1020496,"avatar_url":"https://avatars.githubusercontent.com/u/1020496?v=3","gravatar_id":"","url":"https://api.github.com/users/jorisvandenbossche","html_url":"https://github.com/jorisvandenbossche","followers_url":"https://api.github.com/users/jorisvandenbossche/followers","following_url":"https://api.github.com/users/jorisvandenbossche/following{/other_user}","gists_url":"https://api.github.com/users/jorisvandenbossche/gists{/gist_id}","starred_url":"https://api.github.com/users/jorisvandenbossche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jorisvandenbossche/subscriptions","organizations_url":"https://api.github.com/users/jorisvandenbossche/orgs","repos_url":"https://api.github.com/users/jorisvandenbossche/repos","events_url":"https://api.github.com/users/jorisvandenbossche/events{/privacy}","received_events_url":"https://api.github.com/users/jorisvandenbossche/received_events","type":"User","site_admin":false},"created_at":"2015-07-23T10:00:02Z","updated_at":"2015-07-23T10:00:02Z","body":"Thanks for the reproducible example! That indeeds triggers the error for me as well.\r\n\r\nHere is an example of just a small dataframe that also shows the error (as it has as such nothing to do with the `groupby`, it is just that it creates a multi-index that `to_latex` handles incorrectly):\r\n\r\n```\r\n\r\nIn [22]: df = pd.DataFrame({'a':[0,0,1,1], 'b':list('abab'), 'c':[1,2,3,4]})\r\n\r\nIn [23]: df = df.set_index(['a', 'b'])\r\n\r\nIn [24]: df\r\nOut[24]:\r\n     c\r\na b\r\n0 a  1\r\n  b  2\r\n1 a  3\r\n  b  4\r\n\r\nIn [25]: print(df.to_latex())\r\n\\begin{tabular}{llr}\r\n\\toprule\r\n  &   &  c \\\\\r\n\\midrule\r\n0 & a &    \\\\\r\n  & b &  1 \\\\\r\n1 & a &  2 \\\\\r\n  & b &  3 \\\\\r\n\\bottomrule\r\n\\end{tabular}\r\n\r\n```\r\n\r\nIt seems that all values are shifted one line below."}}