0

I have a Pandas Dataframe where each column is Series of strings. The strings represent the path to files that might be or not be physically present on the hard drive. I would like to mark the path pointing to not existent files, i.e. by coloring the string or its background.

Unfortunately I can't use Styler.applymap(func) because func should take a scalar input, not a string.

Also I just got that anyway Styler wouldn't really work for me because I use the Pycharm python console or the terminal on Ubuntu, not Jupyter

What can I do?


Example function for checking the existence of a file and returning a color

def color_not_existent_file(path):
    color = ('red' if not os.path.exists(path) else 'green')
    return 'color: {}'.format(color)
Robyc
  • 379
  • 1
  • 13
  • what's your end goal? why does it need to be colored vs. adding a flag field to the dataframe? – OverflowingTheGlass Nov 15 '17 at 18:35
  • I don't "need" colors. I need a way to easily check if some files are missing or not. A flag was my first thought, but then I should add one additional column for every existent column in the DataFrame, basically doubling the number of columns. I would prefer not to add so much overhead, hence the idea of coloring. – Robyc Nov 16 '17 at 10:51

0 Answers0