Source code for projit.latex_table

"""
Support function for generating a latex table from a pandas dataframe
This function negates the need for additional dependencies
"""

########################################################################################




[docs] def clean_data_for_latex(input): """ This utility function is required because some strings might contain LaTeX special characters, and therefor need to be escaped before latex rendering will function. """ strdata = str(input) strdata = strdata.replace("%","\\%") strdata = strdata.replace("$","\\$") strdata = strdata.replace("#","\\#") strdata = strdata.replace("^","\\^") strdata = strdata.replace("&","\\&") strdata = strdata.replace("_","\\_") strdata = strdata.replace("{","\\{") strdata = strdata.replace("}","\\}") return strdata