I am trying to display a dataframe in a frame on my tkinter app. I want to group my values by the first 2 columns and get the sum of all the values per unique pair. While working with the dataframe everything is working as expected. Printed in the terminal, my output is exactly what I want, however when displayed in the tkinter frame it cuts off the columns that I group.
This is what I have tried so far:
import pandas as pd
import tkinter as tk
from pandastable import Table
df = pd.DataFrame({
'A': ['A', 'B', 'A', 'A', 'B', 'B'],
'B': ['a', 'a', 'a', 'b', 'b', 'a'],
'C': [3, 1, 4, 1, 5, 9]
})
def order(df):
ordered = df.groupby(['A', 'B']).sum()
print(ordered)
return ordered
root = tk.Tk()
frame = tk.Frame(root)
frame.pack()
pt = Table(frame, dataframe = order(df))
pt.show()
root.mainloop()
Here is a simplified version of what I'm trying to achieve.
The first print gives me what I want:
While the tkinter window cuts off columns A and B:
Any advice on how I could make the tkinter table look like the terminal output would be very much appreciated. Thanks :)