Why Python throws "<pyqtgraph.graphicsItems.PlotDataItem.PlotDataItem at 0x1dc1a1bf670>" when trying to plot a simple boxplot? - python-3.x

I created the following df that contains the following data:
True Price Range
0 0.3151260504201625
1 0.08403361344537472
2 0.3577441077441151
3 0.2773629187113253
4 0.1715633712202524
5 0.4948364888123946
6 0.30068728522337035
7 0.043261951113993474
8 0.4562242016076512
9 0.1527050610820258
10 0.2185314685314596
11 0.9452626950978232
12 0.459016393442627
13 0.48097944905989937
14 0.17459624618071515
15 0.39534372940917983
16 0.44130626654898236
17 0.440237728373319
18 0.4386926957666129
19 0.4149377593361054
20 0.08748906386702823
21 0.21920210434019272
22 6.046511627906989
23 0.1536772777167961
24 0.06590509666081337
25 0.021987686895345346
26 0.46337157987643834
27 0.3077599472411393
28 0.043907793633368136
29 0.17644464049405312
30 0.29082774049218146
31 0.3157419936851629
32 0.49762497172584935
33 0.24797114517584748
34 0.49571879224875615
35 0.2941842045711658
36 0.49661399548532276
37 0.6515389800044902
38 0.4916201117318546
39 0.6037567084078699
40 1.1599375418246702
41 0.2668445630420171
42 0.28882470562096907
43 0.3771073646849967
44 0.17742293191395805
45 0.022158209616654382
46 0.46532240194991115
47 0.3576218149307117
48 0.15642458100558798
49 0.27008777852802623
50 0.3161698283649531
51 0.18289894833103962
52 0.7097069597069705
53 0.5325306783977797
54 0.13879250520472936
55 0.3940658321743243
56 0.1391465677180067
57 0.301694128568109
58 0.1860897883228582
59 0.1638193306810218
I'm trying to plot its corresponding boxplot, based on this guide, I can run df["True Price Range"].plot(kind='box', title='Boxplot of True Price Range') in the Spyder console to get that.
But after doing so, I get the following output:
Out[3]: <pyqtgraph.graphicsItems.PlotDataItem.PlotDataItem at 0x1dc1a1bf670>
Which I don't understand, I also tried:
df["True Price Range"].plot(kind='box', title='Boxplot of True Price Range').show()
And got literally nothing as output, not even errors.
Finally I tried using the Pandas boxplot function (i.e. df.boxplot(column= "True Price Range")) and got the following error:
AttributeError: module 'finplot.pdplot' has no attribute 'boxplot_frame'
Note: Both matplotlib.pyplot and pandas libraries were imported as pd and plt respectively before running the syntax above
May I get some assistance here?

Regarding your first command, the output you get is simply the object type that you have created (pyqtgraph.graphicsItems.PlotDataItem.PlotDataItem) and the memory address where this object is located (0x1dc1a1bf670). There is nothing wrong with this output. If you want to see the plot, you should add plt.show() after this command. Therefore, the code should be:
df["True Price Range"].plot(kind='box', title='Boxplot of True Price Range')
plt.show() # displays the figure
The matplotlib.pyplot.show function displays the figure that you have created.
Regarding the line df["True Price Range"].plot(kind='box', title='Boxplot of True Price Range').show(), you shouldn't call the show method on the object you have just created (i.e., the pyqtgraph.graphicsItems.PlotDataItem.PlotDataItem type). Just call the show method as mentioned above.
Regarding the AttributeError you mention last, it means that the method you want to call does not exist.

Solved by running the following lines:
plt.boxplot(x=df, vert = False)
plt.show() # displays the figure
matplotlib.pyplot must have been imported as plt

Related

replacing a value in python

I'm writing a bingo game in python. So far I can generate a bingo card and print it.
My problem is after I've randomly generated a number to call out, I don't know how to 'cross out' that number on the card to note that it's been called out.
This is the ouput, it's a randomly generated card:
B 11 13 14 2 1
I 23 28 26 27 22
N 42 45 40 33 44
G 57 48 59 56 55
O 66 62 75 63 67
I was thinking to use random.pop to generate a number to call out (in bingo the numbers go from 1 to 75)
random_draw_list = random.sample(range(1, 76), 75)
number_drawn = random_draw_list.pop()
How can I write a funtion that will 'cross out' a number on the card after its been called.
So for example if number_drawn results in 11, it should replace 11 on the card with an x or a zero.

how can get the formula of a data table in excell_

this is my data and im trying to get the formula of it, how can i do it ( it dosent have to be using excell only but i dont know how to do it )
0 2 4 6 8
0 100 90 80 70 60
2 85 64.49 53.5 48.15 50
4 70 48.9 38.43 35.03 40
6 55 38.78 30.39 27.07 30
8 40 35 30 25 20
and this is the graphic that i obtain
but when i try to do an adjustment of the data i cant find the option as in a 2d graph
ok i didnt find how to get the equation for those values but this problem its solved by the bilinear interpolation
i used this video https://www.youtube.com/watch?v=va8vFViss90
and this calculator to make sure that i didnt messed it up https://www.ajdesigner.com/phpinterpolation/bilinear_interpolation_equation.php#ajscroll

How to use ExecWB command for printing pages as pdf

I am trying the below code used to print a webpage as pdf
IE.ExecWB 6, 2, "U:\Translations", Null
I am not sure how to specify the path name in the above syntax .
The parameters as as follows :
object.ExecWB nCmdID, nCmdExecOpt, [pvaIn], [pvaOut]
browser.ExecWB method does not have any parameter to pass the file path.
object.ExecWB nCmdID, nCmdExecOpt, [pvaIn], [pvaOut]
The ExecWB method requires an OLE Command ID to be passed in to identify the command to execute. This value nCmdID is of type Long. The nCmdExecOpt parameter represents the value for the command execution option. Together, these values instruct the control as to what supported command to execute and what degree of user prompting should occur.
The last two parameters pvaIn and paOut are optional and is usually set to either NULL or an empty string.
Here is a complete list for the 1st parameter
OLECMDID_OPEN 1 Open
OLECMDID_NEW 2 Create a new document
OLECMDID_SAVE 3 Preservation
OLECMDID_SAVEAS 4 Save as
OLECMDID_SAVECOPYAS 5
OLECMDID_PRINT 6 Print
OLECMDID_PRINTPREVIEW 7 Print preview
OLECMDID_PAGESETUP 8 Page setup
OLECMDID_SPELL 9 The spelling check
OLECMDID_PROPERTIES 10 Attribute
OLECMDID_CUT 11 Shear
OLECMDID_COPY 12 Replication
OLECMDID_PASTE 13 Paste
OLECMDID_PASTESPECIAL 14 Paste special
OLECMDID_UNDO 15 Revoke
OLECMDID_REDO 16 Repeat
OLECMDID_SELECTALL 17 Select all
OLECMDID_CLEARSELECTION 18 Clear selection
OLECMDID_ZOOM 19
OLECMDID_GETZOOMRANGE 20
OLECMDID_UPDATECOMMANDS 21 The update command
OLECMDID_REFRESH 22 Refresh
OLECMDID_STOP 23 Stop it
OLECMDID_HIDETOOLBARS 24 Hide toolbar
OLECMDID_SETPROGRESSMAX 25 Progress bar maximum
OLECMDID_SETPROGRESSPOS 26 Progress bar position
OLECMDID_SETPROGRESSTEXT 27 Progress bar text
OLECMDID_SETTITLE 28 Set the title
OLECMDID_SETDOWNLOADSTATE 29 Set download status
OLECMDID_STOPDOWNLOAD 30 Stop downloading
OLECMDID_ONTOOLBARACTIVATED 31
OLECMDID_FIND 32 Search
OLECMDID_DELETE 33 Delete
OLECMDID_HTTPEQUIV 34
OLECMDID_HTTPEQUIV_DONE 35
OLECMDID_ENABLE_INTERACTION 36 Allow the interaction
OLECMDID_ONUNLOAD 37 When uninstall
OLECMDID_PROPERTYBAG2 38
OLECMDID_PREREFRESH 39
OLECMDID_SHOWSCRIPTERROR 40
OLECMDID_SHOWMESSAGE 41 Display a message
OLECMDID_SHOWFIND 42 Display search
OLECMDID_SHOWPAGESETUP 43 Display page setup
OLECMDID_SHOWPRINT 44 Display and printing
OLECMDID_CLOSE 45 Close
OLECMDID_ALLOWUILESSSAVEAS 46
OLECMDID_DONTDOWNLOADCSS 47
OLECMDID_UPDATEPAGESTATUS 48
OLECMDID_PRINT2 49 Print 2
OLECMDID_PRINTPREVIEW2 50 Print preview
OLECMDID_SETPRINTTEMPLATE 51 Set the print template
OLECMDID_GETPRINTTEMPLATE 52 Get a print template
OLECMDID_PAGEACTIONBLOCKED 55
OLECMDID_PAGEACTIONUIQUERY 56
OLECMDID_FOCUSVIEWCONTROLS 57
OLECMDID_FOCUSVIEWCONTROLSQUERY 58
OLECMDID_SHOWPAGEACTIONMENU 59
OLECMDID_ADDTRAVELENTRY 60
OLECMDID_UPDATETRAVELENTRY 61
OLECMDID_UPDATEBACKFORWARDSTATE 62
OLECMDID_OPTICAL_ZOOM 63
OLECMDID_OPTICAL_GETZOOMRANGE 64
OLECMDID_WINDOWSTATECHANGED 65 windows status change
Here is a complete list for the 2nd parameter
OLECMDEXECOPT_DODEFAULT 0 Default parameters
OLECMDEXECOPT_PROMPTUSER 1 Prompt the user, namely the pop-up dialog box
LECMDEXECOPT_DONTPROMPTUSER 2 User is not prompted
OLECMDEXECOPT_SHOWHELP 3 displays help
IE.ExecWB method can be used to print the web page as PDF but it will prompt the user to select the folder and ask the file name to save it.
This method does not have any parameter to pass the file path. So if you are looking for using the path written in your code than you need to change your logic and modify your code based on that.
References:
(1) ExecWB method
(2) Microsoft Internet Controls

Missing Date xticks on chart for matplotlib on Python 3. Bug?

I am following this section, I realize this code was made using Python 2 but they have xticks showing on the 'Start Date' axis and I do not. My chart only shows Start Date and no dates are provided. I have attempted to convert the object to datetime but that shows the dates and breaks the graph below it and the line is missing:
Graph
# Set as_index=False to keep the 0,1,2,... index. Then we'll take the mean of the polls on that day.
poll_df = poll_df.groupby(['Start Date'],as_index=False).mean()
# Let's go ahead and see what this looks like
poll_df.head()
Start Date Number of Observations Obama Romney Undecided Difference
0 2009-03-13 1403 44 44 12 0.00
1 2009-04-17 686 50 39 11 0.11
2 2009-05-14 1000 53 35 12 0.18
3 2009-06-12 638 48 40 12 0.08
4 2009-07-15 577 49 40 11 0.09
Great! Now plotting the Difference versus time should be straight forward.
# Plotting the difference in polls between Obama and Romney
fig = poll_df.plot('Start Date','Difference',figsize=(12,4),marker='o',linestyle='-',color='purple')
Notebook is here

LabVIEW array index

I am new to LabVIEW programming, and the problem is, that I need index numbers of each element in a array, and also select values by those indexes into another array, like so:
Array 13 15 16 17 18 19 12 17 17 162 626 36 828 463 565 665 565 32 587
Index 5 6 7 8 9 12 13 14 20 22 23 24 25 26 27 28 29 30 21
In the result program should get these index values .
Thanks in advance!
Upd: here is code snippet of how to get indexes of elements in the array.
Also, there is OpenG Array library (you could install it via VI Package Manager), it has built-in function of how to get all entries of element (see it on the picture).
Below is the code snippet for search in 2D array:
Update: search 2D array in 2D array, LV2013 snippet

Resources