0

Whenever I run this code on jupyter notebook, it produces the correct highlighted dataframe:

import pandas as pd
import numpy as np
np.random.seed(24)
df = pd.DataFrame({'A': np.linspace(1, 10, 10)})
df = pd.concat([df, pd.DataFrame(np.random.randn(10, 4), columns=list('BCDE'))],
               axis=1)

def highlight_greaterthan(x):
    if x.C > .5:
        return ['background-color: yellow']*5
    else:
        return ['background-color: white']*5 
df.style.apply(highlight_greaterthan, axis=1)

However, when I run it in my mac terminal, I received this output:

<pandas.io.formats.style.Styler object at 0x118a6e198>

I was wondering how I would be able to run this through the terminal and receive the output with the highlighted dataframe. Thank you for any help.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
FrankMank1
  • 73
  • 6

1 Answers1

0

I believe this is due to the IDE. Try printing it.

formicaman
  • 1,317
  • 3
  • 16
  • 32
  • Printing it results in the same output: . Does that mean pandas styler would only work in specific ides? It seems like I should be able to at least save the highlighted dataframe but that doesn't seem to work either – FrankMank1 May 15 '20 at 19:36