[Python] Fit the rows and column names using pandas.set_option

Discussão em 'Python' iniciado por Stack, Julho 25, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to use pandas.set_option for my python script to display a table but some how the data does not fill properly in an html page Since the names in some column are bit longer , columns look 1 below another

    Is it possible to split the entries eg: in "Log File" column so that the table will look better . I want to ensure I am able to read the Log file name completely and try to display the complete table .

    Is it possible to display the complete table properly where I am able to read all the contents in a readable way

    Below is a screenshot of the output from the html page:

    [​IMG]

    Below is the code snippet:

    def print_table(self, test_result: dict) -> None:

    sf_detection_table = {
    "Log File ": test_result["Log"],
    "Total Sf Percentage Epochs (Fix type 1 and 4)": test_result[
    "Total Sf Percentage Epochs (Fix type 1 and 4)"
    ],
    "Sf DR Percentage Epochs (Fix type 1)": test_result["Sf DR Percentage Epochs (Fix type 1)"],
    "Sf GNSS DR Percentage Epochs (Fix type 4)": test_result["Sf GNSS DR Percentage Epochs (Fix type 4)"],
    "HPG Fixed Ambuity Percentage Epochs (Carr sol=2)": test_result[
    "HPG Fixed Ambuity Percentage Epochs (Carr sol=2)"
    ],
    "HPG Float Percentage Epochs (Carr sol=1)": test_result["HPG Float Percentage Epochs (Carr sol=1)"],
    }
    pd.set_option("display.max_colwidth", None)
    pd.set_option("display.max_columns", None)

    logger.info(pd.DataFrame(sf_detection_table))

    Continue reading...

Compartilhe esta Página