0

Here is an example Data Frame

import pandas as pd
from prettytable import PrettyTable

df = pd.DataFrame()
df["name"] = ["Nick","Bob", "George", "Jason","Death"]
df["Restaurant Manager"] = ["Sam","Mason", "Sam", "Mason","Mason"]
df["Score"] = [1,5, 7, 2,10]
df['Percentile Rank'] = [0,50,80,20,100]
df["Restaurant Name"] = "Elise"

What I am trying to do is to recreate this table (see screenshot) that we have in excel since we are in the process of trying to automate our reporting system.

enter image description here

I managed to get something a bit similar to this but I am stuck... Here is the following code:

#Add headers
column_names = ["Rank","Employee Name", "Score", "Percentile"]#Add columns
tb1.add_column(column_names[0],[1,2])
tb1.add_column(column_names[1],["Nick","George"])
tb1.add_column(column_names[2],[1,7])
tb1.add_column(column_names[3],[0,80])
tb1.title = "Elise"
print(tb1)

Not only would I like to replicate the table fully as in the image shared above. But I would also like to create multiple similar tables for each restaurant name and place them side by side if possible.

1 Answer 1

1

Create it from a dictionary:

df = pd.DataFrame({
    "name": ["Nick","Bob", "George", "Jason","Death"],
    "Restaurant Manager": ["Sam","Mason", "Sam", "Mason","Mason"],
    "Score": [1,5, 7, 2,10],
    'Percentile Rank': [0,50,80,20,100],
    "Restaurant Name": ["Elise", "Elise", "Elise", "Elise", "Elise"]
})
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.