I just want to know how I can create a variable from Unique values in a Database, for example: If I had a database with Chemical Name as a Column how could I alter the code so that the unique values in Chemical Name could be called individually. Lets say Ethylbenzene is a chemical in the database, every time I use the GUI I can select Ethylbenzene from the drop down box and analyze the data relevant to just Ethylbenzene.
So far my code is this: Code for GUI=
class Dialog(QDialog):
"""Dialog."""
def __init__(self, parent=None):
"""Initializer."""
super().__init__(parent)
self.setWindowTitle('QDialog')
self.draw_self()
def draw_self(self):
dlgLayout = QVBoxLayout()
formLayout = QFormLayout()
chem_name = QLineEdit()
tissue = QLineEdit()
study_meth = QLineEdit()
sex = QLineEdit()
formLayout.addRow('Chemical Name:', chem_name)
formLayout.addRow('Tissue Under Study:', tissue)
formLayout.addRow('Study Methodology:', study_meth)
formLayout.addRow('Sex:', sex)
dlgLayout.addLayout(formLayout)
btns = QDialogButtonBox()
btns.setStandardButtons(
QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
dlgLayout.addWidget(btns)
self.setLayout(dlgLayout)
if __name__ == '__main__':
app = QApplication(sys.argv)
dlg = Dialog()
dlg.show()
sys.exit(app.exec_())
Code for Reading file:
import pandas as pd
nba = pd.read_csv("Micronucleus.csv")
type(nba)
nba["Chemical Name"].value_counts()
nba['Chemical Name'].unique().tolist()