Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

python - Tkinter, how to make a scatter graph pop up into a new window

I have this program that takes 3 known csv files, merges them into one using there common column headings. It then gives you the option to 'clean' them and display some data analysis.

The data analyses I wish to display are the mean, mode, median and a correlation scatter graph using 2 columns.

So far my code does exactly that but I have 2 separate problems:

  1. 2 columns 'Score' and 'Zip Code'. I want to give the mean score for zipcode but because it is big database, my GUI on tkinter does not display all the zip codes with the mean scores. Is there a way I can make tkinter show all the mean values, or if not is there a way I can make the user type the zipcode and the mean value for that zip code is shown?

  2. More importantly, I am using jupyter notebook, so when I launch my GUI and display the scatter graph, instead of a new window opening with this scatter graph, the graph is being printed into the jupyter console, as if I have done a 'print' command.

Here is the code for the function which does this:

#Datebase file = CombinedFinal

def dataButton(self):
        #eliminate entries that do not have a zip code or violation code.
        self.ViolationOnly = self.CombinedFinal [self.CombinedFinal ['VIOLATION CODE'].isna() == False]
        self.ViolationOnly = self.ViolationOnly[self.ViolationOnly ['Zip Codes_y'].isna() == False]
    
        #grouping the score with the zipcode
        GroupSeatingScoreA = self.CombinedFinal['SCORE'].groupby(self.CombinedFinal['Zip Codes_y'])
        
        GroupZip = self.ViolationOnly.groupby(by='Zip Codes_y', as_index=False).agg({'SERIAL NUMBER': pd.Series.nunique})
        plt.scatter(GroupZip['Zip Codes_y'], GroupZip['SERIAL NUMBER'])
        plt.show()
        
        output.configure(state='normal')
        output.insert(tk.END, GroupSeatingScoreA.mean())
        output.configure(state='disabled')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...