I have been learning NumPy arrays/matrices in Python. As I worked, I found that I desired a more readable form of 3d matrices. So I figured that writing one would be a good goal and learning exercise. The goal was to create a function that would print 3d NumPy matrices out in a more readable 'tower' form, but without altering the original matrix or duplicating it . I accomplished the goal, and learned much about NumPy, and output formatting. If you too desire to have 3d matrices displayed in a more readable form, then this should do the trick. Enjoy. … |
+0 forum
0 | ||

Hello, I have an one dimension numpy array with 1 to 5 numbers. I need to map these values to corresponding numbers between 0.76 to 1.24 with 0.12 interval. Then the problem is the find exact values in one array and fill the exact index in the second array. for example: `array([1,2,1,3,4,5])` Should be: `array([0.76,0.88,0.76,1,1.12,1.24])` I did this using if,elif but I though there has to be a elegent way to do this. def ClassConv(classNumVec): relativeMilk = np.empty([size]) for i in range(size): if classNumVec[i] == 1: relative[i] = 0.76 elif classNumVec[i] == 2: relative[i] = 0.88 elif classNumVec[i] == 3: … |
+0 forum
1 | ||

I have two text files and I want to compare them and save the matched columns to a new text file. file1: 114.74721 114.85107 114.85107 2.96667 306.61756 file2: 115.06603 0.00294 5.90000 114.74721 0.00674 5.40000 114.85107 0.00453 6.20000 111.17744 0.00421 5.50000 192.77787 0.03080 3.20000 189.70226 0.01120 5.00000 0.46762 0.00883 3.70000 2.21539 0.01290 3.50000 2.96667 0.01000 3.60000 5.43310 0.00393 5.50000 0.28537 0.00497 5.10000 308.82348 0.00183 6.60000 306.61756 0.00359 5.20000 And I want the output to be 114.74721 0.00674 5.40000 114.85107 0.00453 6.20000 114.85107 0.00453 6.20000 2.96667 0.01000 3.60000 306.61756 0.00359 5.20000 I used a script but the output file is empty, Could … |
+0 forum
5 | ||

Code Snippet
Loan calculation using Python module numpy Just another loan calculation, this time using a handy function in Python module numpy. |
+3 forum
1 | ||

Hi everyone, I just downloaded and installed numpy, and I'd like to give it a try. But I can't seem to import it. When I try, this is what happens: Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> from numpy import * Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> from numpy import * ImportError: No module named 'numpy' >>> I downloaded and installed the 64-bit version; is that the problem? Or do I need to somehow set up the paths properly? |
+0 forum
4 | ||

Hi, I want to identify the datatypes of the te entire dataframe and group it as String, Number and Date. Required Output: Attributes Datatype A String B Number C String As of now I am using the code: for col_number in range(len(data_frame.columns)): datatype = data_frame[data_frame.columns[col_number]].apply(type).unique()[0] if (datatype is np.str or datatype is str) and data_frame.columns[col_number] != "DOP": fattr_dict[data_frame.columns[col_number]] = "String" elif datatype is np.int64 or datatype is np.int32 or datatype is float or datatype is np.float64: fattr_dict[data_frame.columns[col_number]] = "Number" elif datatype is np.datetime64 or data_frame.columns[col_number] == "DOP": fattr_dict[data_frame.columns[col_number]] = "Date" My question is how do I get the required format. |
+0 forum
0 | ||

Hi, I have a list which contains strings in each value. I want the word count of each string and then I will have to find out the string with minimum word count and max. word count in that list. Help is much appreciated. |
+0 forum
3 | ||

I have NO IDEA how to use Python. Best answer if you write the full program! Please help me! I will be forever grateful! Accept / Reject Monte Carlo Part I: Goal: Write a python program that will: 1. define a function for a specific probability density function f(x), 2. define a function that will sample from f(x) using the accept/reject Monte Carlo algorithm, 3. make a histogram of the samples and compare to f(x). Recall the accept / reject algorithm is: I. generate a uniformly random value of x (in its range) II. generate a uniformly random value y … |
-2 forum
1 | ||

I have this programme to discuss and I think its a challenging one.. Here I have a yml file which contains the data for an image. The image has x,y,z values and intensity data which is stored in this yml file. I have used opencv to load the data and its working fine with masking.. but I am having problems in dynamically appending the masks created.. Here is the code I made for solving the problem : import cv from math import floor, sqrt, ceil from numpy import array, dot, subtract, add, linalg as lin mask_size = 9 mask_size2 = … |
+0 forum
0 | ||

How to load a yml file in python and work with it ?? I used : import cv data = cv.Load("Z:/data/xyz_00000_300.yml") But when I print data.. it just gives the detail of the image like number of rows and columns etc.... I want read what is there in the pixel of the image.. I tried to use the following code .. but it gives me only the pixel values not the information contained in pixel ?? def AccessPixels(img): for y in range(0, img.height): for x in range(0, img.width): cv.Get2D(img, y, x) # Slow get pixel value. cv.Set2D(img, y, x, (0, … |
+0 forum
0 | ||

Hey guys, I had a quick question. Let me try to explain what I'm trying to do here. I'm a bit new to numpy and I'm writing a parallelized code. It is working fine without the use of NumPy, but I'm trying to learn by getting it to work both ways (and I've heard that mpi4py is faster with NumPy as well). So I have a variable amount of numpy column stacks, which as you can see in the code... I want to make vstacks out of all of them in some manner where I don't lose any data. for … |
+0 forum
2 | ||

Hey everyone, I'm trying to install numpy on a 64 bit SUSE linux (HPC) machine that I don't have root on. I've tried about a hundred different ways of doing it off of google and all seem to be failing at one stage or another. I'm starting by installing lapack from source, then atlas linked to lapack from source, and then numpy build after exporting LAPACK, BLAS, and ATLAS. Does anyone have a step by step on how I can get this up and working. If you need any more info I would gladly supply whatever you need. I really … |
+0 forum
1 | ||

Code Snippet
Putting data to bins Here is example how data can be summed to dictionary or you can use numpy.histogram to sum the data as weights of the categorized data. |
+2 forum
5 | ||

Hi I've seen a function in numpy ([URL="http://docs.scipy.org/doc/numpy/reference/generated/numpy.gradient.html"]http://docs.scipy.org/doc/numpy/reference/generated/numpy.gradient.html[/URL]) for calculating the gradient of a 2-dimensional array. Numpy also provides 2 examples on that website (I'm more interested in the second one). I now want to use such a function in C++. Does anyone know if there is such a function in GSL? Or can someone explain to me what the numpy function does, so that I can write my own in C++? Thanks for any help. |
+0 forum
2 | ||

I have saved a 2D matrix in a numpy file (.npy) in python. Is there a way I can access the same from C++ and possibly read in the values in a stl vector? [URL="http://www.scipy.org/C++_Extensions_that_use_NumPy_arrays"]This [/URL] is vaguely relevant. But here you make the call from python. I want to read the matrix file independently in c++. Any suggestions? |
+0 forum
3 | ||

I am trying to find the position of the maximum number in a 2D array. i have used .max() to find the max value but how do i find its position? |
+0 forum
4 | ||

hello! can you please help me with fast numpy transform. i have qimage (argb32) converted to numpy, so it's now an array of shape (128,128,4). and i want the fastest way to convert it to grayscale - the formula is (pseudocode): [CODE]lerp(PIX, dot(PIX, (0.299, 0.587, 0.114)), alpha)[/CODE] where PIX - is current pixel (image[[i][j][:-1]]) rgb, alpha is for blending between gray and color. i am new for numpy, as i see the examples maybe there is a one-stroke-solution for it, very fast.. thank you! |
+0 forum
1 | ||

Hi everyone.. I'm new to python, the more to matplotlib :( and I am hoping that I can get help from this community... :) I have a .csv file, first column is a time stamp with format HH:MM:SS, next 8 columns are values of different parameters. I want to plot each parameter against the time it is taken, in this case, against the time as indicated by the time stamp... How do I convert the time stamp into something which is can be understood by matplotlib? please help me on this... :) Thank you! |
+0 forum
8 |

The End.