簡體   English   中英

Python:用 Z7C2C714003D576477AFEZ8E8B8 格式化 Pandas dataframe 頭

[英]Python: Formatting a Pandas dataframe head with LaTex

I have made a Pandas dataframe from several Z3B7F949B2343F9E5390​​E29F6EF5E1778Z arrays and tried to format columns heads using LaTex, but it looks awful. 我正在使用 Jupyter Notebook。

import numpy as np
import pandas as pd

Arrays(五分之一)如下所示:

coeficientes = [0.5601, 0.3315, 0.2260, 0.1429, 0.0695]
coeficientes = np.array(coeficientes)

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

它的外觀:

在此處輸入圖像描述

是否有任何格式選項可以使它看起來更好?

嘗試這個:

Function 轉換為下標

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM