Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

524
Vistas
Making Multi-row work in pandas dataframe.to_latex()

I have the following dataframe:

      dataset Baseline       Version2      
               F-1   F-2      F-1   F-2
0       G    0.971 0.967    0.971 0.967
1       H    0.780 0.762    0.800 0.777
2       S    0.401 0.320    0.453 0.365
3       T    0.881 0.825    0.989 0.985

My goal is to export this to LaTeX, which I do by pandas.DataFrame.to_latex():

latex = df.to_latex(
        index=False,
        escape=False,
        sparsify=True,
        multirow=True,
        multicolumn=True,
        multicolumn_format='c',
        position='H'
    )

obtaining the following code in LaTeX:

\begin{table}[H]
\centering
\begin{tabular}{lrrrr}
\toprule
dataset & \multicolumn{2}{c}{Baseline} & \multicolumn{2}{c}{Version2} \\
        &      F-1 &   F-2 &      F-1 &   F-2 \\
\midrule
      G &    0.971 & 0.967 &    0.971 & 0.967 \\
      H &    0.780 & 0.762 &    0.800 & 0.777 \\
      S &    0.401 & 0.320 &    0.453 & 0.365 \\
      T &    0.881 & 0.825 &    0.989 & 0.985 \\
\bottomrule
\end{tabular}
\end{table}

which is rendered like this: enter image description here My issue is: I'd expect a multirow to appear in the "dataset", covering the 2 lines with "dataset" and "", like this: enter image description here I have multirow=True in the options, but I can't make this work. Any idea on how can I fix this?

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda