Skip to content

special Latex characters are not escaped in some table cells with Summary.as.latex() #5297

Closed

Description

@jmviz

With statsmodels 0.9.0:

Modifying the example from #2862:

import numpy as np
import statsmodels.api as sm
import statsmodels.formula.api as smf

dat = sm.datasets.get_rdataset("Guerry", "HistData").data

# Rename 'Lottery' column to 'Lottery_'
dat.rename(columns = {'Lottery':'Lottery_'}, inplace = True)

results = smf.ols('Lottery_ ~ Crime_prop + np.log(Pop1831)', data=dat).fit()

print(results.summary().as_latex())

The printed Latex successfully escapes the underscore in Crime_prop:

\textbf{Crime\_prop} & 0.0029 & 0.001 & 3.887 & 0.000 & 0.001 & 0.004 \\

but does not escape the underscore in Lottery_:

\textbf{Dep. Variable:} & Lottery_ & \textbf{ R-squared: } & 0.351 \\

I therefore can't produce a valid latex table when the dependent variable has an underscore.

Activity

  1. added this to the 0.10 milestone on Dec 6, 2018
  2. josef-pkt commented on Dec 6, 2018

    @josef-pkt
    Member

    this got lost without labels.
    AFAICS, there is no recent PR that fixed this.

    bump for 0.10

  3. self-assigned this
    on May 10, 2019
  4. added a commit that references this issue on May 10, 2019
    90c0226
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions