0

I've been using the Series.to_latex() method to generate a table in my LaTeX doc as it follows:

section.append(NoEscape(s.transform(lambda x: f"{x:,}").to_latex()))

My Serie looks like this:

All channels    1099592
Telefe           158738
El Trece         127082
America TV       109763
TN                64598
El Nueve          43450
A24               37639
C5N               36800
ESPN              29356
LN +              27006
Cronica TV        25140
Name: Total:, dtype: int64

But since yesterday my script shows the following output:

FutureWarning: In future versions `DataFrame.to_latex` is expected to utilise the base implementation of `Styler.to_latex` for formatting and rendering. The arguments signature may therefore change. It is recommended instead to use `DataFrame.style.to_latex` which also contains additional functionality.
  section.append(NoEscape(s.transform(lambda x: f"{x:,}").to_latex()))

But when I try to implement the s.style.to_latex() or s.style.format(thousands = ",").to_latex() statements I get the following error:

AttributeError: 'Series' object has no attribute 'style'

I'm not sure the style is properly implemented for Series since i haven't found any indication of in in the API reference

My question here is if there's a way to prevent this warning from happening since it might be depricated in the future, and to optimize my code

Thanks in advance

Seba Rossi
  • 91
  • 7

1 Answers1

1

The error does say the attribute is not for a series, while the warning shows to be applied to a dataframe. I would try:

pd.DataFrame(s).style.to_latex()  

or

pd.DataFrame(s).style.format(thousands = ",").to_latex()
chitown88
  • 27,527
  • 4
  • 30
  • 59