Skip to content
Advertisement

Tag: arrays

Array Manipulation Hackerrank using python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question This logic is working for most of the test cases but not all. What I am doing wrong? Answer None of the python samples pass

How is the dtype of a numpy array calculated internally?

I was just messing around with numpy arrays when I realized the lesser known behavior of the dtypes parameter. It seems to change as the input changes. For example, gives dtype(‘int32’) However, gives dtype(‘int64’) So, my first question is: How is this calculated? Does it make the datatype suitable for the maximum element as a datatype for all the elements?

Convert dataframe to a rec array (and objects to strings)

I have a pandas dataframe with a mix of datatypes (dtypes) that I wish to convert to a numpy structured array (or record array, basically the same thing in this case). For purely numeric dataframes, this is easy to do with the to_records() method. I also need the dtypes of pandas columns to be converted to strings rather than objects

cv2.imshow() giving black screen

I’m converting a image (numpy array) into a string. Then I’m converting this string back to a numpy array of the original dimensions. Hence both the numpy arrays are equal- infact numpy.array_equals() also returns True for the arrays being equal. When I call cv2.imshow() on the original numpy array, it prints the image. But when I call cv2.imshow() on the

Expanding/Zooming in a numpy array

I have the following array: I want to expand it to this array: So I’m using the following command: based on this question and answer here Resampling a numpy array representing an image. However, what I’m getting is this: I want the expansion to be exactly by 3, or whatever the zoom factor is, but currently it’s different for each

How to make c++ return 2d array to python

I find an example showing how to return a 1D array from c++ to python. Now I hope to return a 2D array from c++ to python. I imitate the code shown in the example and my code is as follows: The file a.cpp: The file b.py: I run the following commands: Then I get the following prints: It seems

Advertisement