brackets - Python - what is this syntax? my_2d_list[0:20,1] -


To find out what's inside the bracket, a difficult time with an interpreter is Google or nude. The reference is the code: matplotlib.mlab import from mlabPCA mlab_pca = mlabPCA (all_samples.T.) In the form of PCA ('in terms of measurement axes' from PC axis '\' standard Increased deviation: \ n ', \ mlab_pca.Wt) plt.plot (mlab_pca.Y [0: 20,0], mlab_pca.Y [0: 20,1],' o ', markers = 7, \ color =' Blue ',' alpha = 0.5, label = 'class1') plt.plot (mlab_pca.Y [20: 40,0], mlab_pca.Y [20: 40,1], '^', marker size = 7, \ Color = 'red', alpha = 0.5, label = 'class2') plt.xlabel ('x_values') plt.ylabel ('y_values') plt.xlim ([- 4,4]) plt. Ylim ([- 4,4]) plt.legend () plt.title ('matplotlib.mlab.PCA (to be replaced with class labels') plt.show ()

I have Tried to create a small 2D array

  a = [[1,2], [1,2], [1,2], [1,2], [1] , 2]]   

and evaluation

  a [0: 2.0]   

But he did something to me Not even thank you!

The code taken from the "using the PCA (class) matplotlib.mlab library" section.

After "text" itemprop = "text">

Indigenous Python Lists (which you are creating for a ) Do not support indexing or skiing, at least in the way you are doing this, to use index and slice, you can use syntax, because you are already using it:

  1. To use index and slice
    1.   np a = np.array ([[1,2], Samples as [1,2], [1,2], [1,2], [1,2] Importing]] [0: 2, 0] # Returns array ([1, 1])   
      1. Your original python list with a different syntax Log in.

        This method does not really allow you to split the way you are using it, but, you can: a [0 ] [1] to access 0, 1 element correctly with a [0, 1] list. But again, a piece of action ( one [0: 2] [0] will produce some unwanted results).

        It seems that you may have syntax options based on some, if so, then use this great reference guide to reduce the infection:

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -