1

I want to make some comparison of algorithm scores in the table. In my program I have four algorithms, so there are always four rows. I want all of these data in one table.

This is a part of program when user chooses how many points will be considered. In the example below we have 5 points, because user chose 5.

d1 = {1: 1.0, 2: 0.5, 3: 0.25, 4: 0.5, 5: 0.25}
d2 = {1: 0.0, 2: 0.25, 3: 0.25, 4: 0.5, 5: 0.25}
d3 = {1: 0.8333333333333333, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0.0}
d4 = {1: 0.1453355124360636, 2: 0.17621944768308642, 3: 0.17621944768308642, 4: 0.3260061445146773, 5: 0.17621944768308642}

But the user can also choose different number of points which will be considered. So at the beginning we don't know how many columns we will have. Because of this irregularity of size of dictionary, I'm not sure how to create one whole table.

I tried something like that for one of the algorithms:

for row in zip(*([key] + (value) for key, value in sorted(d1.items()))):
    print(*row)

but it doesn't working for this one. So as I don't know how to make this for one algorithm, I don't know how to do that for all of them.

Do you have any hints of ideas of solution?

It should be something like that:

enter image description here

2
  • 2
    Using your example above, what do you want the output to look like? Commented May 12, 2021 at 14:14
  • @itprorh66 I added the output I want above Commented May 12, 2021 at 14:21

1 Answer 1

3

This is how I would do it:

df = pd.DataFrame([d1,d2,d3,d4], index=['d1','d2','d3','d4'])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.