Skip to content Skip to sidebar Skip to footer

Texttable Draw Changes The Format Of The Content

I'm trying to draw a table with texttable. I have this piece of code to arrange the content of the table: def get_int_avg_pre(r_list, p_list): li = [] recall_list = [0.0, 0.1, 0.2,

Solution 1:

The problem was that if no type specified for the values of columns, auto type is assigned to it. It means most possible type will be evaluated. Since 1.0 or 0.0 is closer the integer than float, they were converted to int. For the rest, they were closer to float and converted accordingly with a default precision 3.

The solution in my case was to use

t.set_cols_dtype(["t", "t"])

just before the line

tt.add_rows(printed_list)

to give the specific field types. I used text as in my case I already formatted my input however, texttable supports float with a configurable precision as field type hence using it was also probable.


Post a Comment for "Texttable Draw Changes The Format Of The Content"