I am currently practicing pandas
I am using some pokemon data as a practice https://gist.github.com/armgilles/194bcff35001e7eb53a2a8b441e8b2c6
i want to make a program that allows the user to input their queries and I will return the result that they need.
i have a little problem where if i show the results of my pandas query in pysimplegui, it shows an ''ugly'' result unlike in the terminal that is ''pretty'. To be more clear with my problem, here is an example.
If I query this:
the result after i press "search" will be
but if i look at the results in the terminal, it looks like this
here is my working code
import pandas as pd
import PySimpleGUI as sg
pd.set_option('display.max_rows', None)
df = pd.read_csv(r'PATH HERE')
layout = [ [sg.Text('This is a basic searcher \nPlease input your search parameters')],
[sg.Text('Name'), sg.Input(key='Name')],
[sg.Text('Type 1'), sg.Input(key='Type 1')],
[sg.Text('Type 2'), sg.Input(key='Type 2')],
[sg.Text('Total'), sg.Input(key='Total')],
[sg.Text('Generation'), sg.Input(key='Generation')],
[sg.Button('Search'), sg.Button('Close')]
]
window = sg.Window('Pokemon Database Query', layout).Finalize()
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Close':
break
if event == 'Search':
df_query = 'df.loc['
for key,value in values.items():
if value != '':
if value.isnumeric():
df_query += f'''(df['{key}'] == {value})&'''
else:
df_query += f'''(df['{key}'] == '{value}')&'''
df_query = df_query[:-1] + ']'
sg.popup_scrolled('Result', eval(df_query))
window.close()
thank you