[英]Python: Formatting a Pandas dataframe head with LaTex
I have made a Pandas dataframe from several NumPy arrays and tried to format columns heads using LaTex, but it looks awful. I have made a Pandas dataframe from several Z3B7F949B2343F9E5390E29F6EF5E1778Z arrays and tried to format columns heads using LaTex, but it looks awful. I'm working with Jupyter Notebook.
我正在使用 Jupyter Notebook。
import numpy as np
import pandas as pd
Arrays (one instance out of five) look like this: Arrays(五分之一)如下所示:
coeficientes = [0.5601, 0.3315, 0.2260, 0.1429, 0.0695]
coeficientes = np.array(coeficientes)
The dataframe: dataframe:
tabla_resumen = pd.DataFrame({'$x_{n-i+1}$': submuestra1,
'$x_{i}$': submuestra2,
'$x_{n-i+1} - x_{i}$': diferencias,
'$a_{n-i+i}$': coeficientes,
'$(x_{n-i+1} - x_{i})(a_{n-i+i})$': sumandos
})
tabla_resumen
The way it looks:它的外观:
Are there any formatting options to make it look better?是否有任何格式选项可以使它看起来更好?
Try this:尝试这个:
def get_sub(x):
normal = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-=()"
sub_s = "ₐ₈CDₑբGₕᵢⱼₖₗₘₙₒₚQᵣₛₜᵤᵥwₓᵧZₐ♭꜀ᑯₑբ₉ₕᵢⱼₖₗₘₙₒₚ૧ᵣₛₜᵤᵥwₓᵧ₂₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎"
res = x.maketrans(''.join(normal), ''.join(sub_s))
return x.translate(res)
print('H{}SO{}'.format(get_sub('2'),get_sub('4'))) #H₂SO₄
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.