I have a dataframe with 3 columns: Date, attribute_one, attribute_two. The date column is blank but the other two columns are filled with some data. how can I use tkinter package to build a GUI which would prompt the user to enter date which will then be eventually stored in the dataframe.
Advertisement
Answer
Using the tkinter Entry class, and using a list, you can easily accomplish so.
JavaScript
x
21
21
1
from tkinter import *
2
3
tk = Tk()
4
5
def add_data():
6
o = i.get()
7
code = o
8
print(code)
9
10
i = Entry(tk)
11
12
i.pack()
13
14
code = str()
15
16
btn = Button(tk, command = add_data, text='Add')
17
18
i.pack()
19
20
btn.pack()
21
You can then add it to the column. If you want to ask them in the console, use this instead:
JavaScript
1
8
1
import sys
2
3
print('Please enter the date.')
4
5
i = str(sys.stdin.readline())
6
7
print(i)
8
Then just add the variable i to your dataframe.