Home > Back-end >  Please help me to print the following python codes in tkinter
Please help me to print the following python codes in tkinter

Time:10-20

I have tried to print the print(df.nlargest(3,'Height')) in the terminal, but I am not sure how it works in Tkinter.

This is the codes:


#importing pandas as pd
from tkinter import *
from tkinter import ttk
import pandas as pd

root = Tk()

root.geometry("100x70")
#creating DataFrame
df= pd.DataFrame({'Name':['Chetan','yashas','yuvraj','Pooja','Sindu','Renuka'],'Age':  [20,25,30,18,25,20],'Height': [155,160,175,145,155,165],'Weight': [75,60,75,45,55,65]})

print(df.nlargest(3,'Height'))

root.mainloop()

Please let me know if there is way to print those 3 largest in the Tkinter Treeview.

Thanks for your help!

Thanks for your help!

CodePudding user response:

Try adding a label:

from tkinter import *
from tkinter import ttk
import pandas as pd

root = Tk()

root.geometry("100x70")
# creating DataFrame
df = pd.DataFrame({'Name': ['Chetan', 'yashas', 'yuvraj', 'Pooja', 'Sindu', 'Renuka'], 'Age': [20, 25, 30, 18, 25, 20],
                   'Height': [155, 160, 175, 145, 155, 165], 'Weight': [75, 60, 75, 45, 55, 65]})

largest_items = df.nlargest(3, 'Height')
data_label = Label(root, text=str(largest_items))
data_label.pack()

root.mainloop()
  • Related