What is monkey patching??

I am trying to understand, what is monkey patching or a monkey patch? Is that something like methods/operators ove...

Python: Convert timedelta to int in a dataframe?

I would like to create a column in a pandas data frame that is an integer representation of the number of days in a ...

Python Implementation of Viterbi Algorithm?

I'm doing a Python project in which I'd like to use the Viterbi Algorithm. Does anyone know of a complete Python im...

Add numpy array as column to Pandas data frame?

I have a Pandas data frame object of shape (X,Y) that looks like this: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] and a nu...

Watermark GIF with Python PIL?

I'm trying to find a way to watermark a gif image, below is my code: img = Image.open("my.gif") watermark = Image.o...

Deep copy of a np.array of np.array?

I have a numpy array of different numpy arrays and I want to make a deep copy of the arrays. I found out the followi...

Convert numpy array to tuple?

Note: This is asking for the reverse of the usual tuple-to-array conversion. I have to pass an argument to a (wrapp...

convert nan value to zero?

I have a 2D numpy array. Some of the values in this array are NaN. I want to perform certain operations using this a...

What does .shape[] do in “for i in range(Y.shape[0])”??

I'm trying to break down a program line by line. Y is a matrix of data but I can't find any concrete data on what .s...

How to Execute a Python File in Notepad ++??

I prefer using Notepad ++ for developing, How do I execute the files in Python through Notepad++? ...

Turtle graphics, draw a star??

I want to draw a filled-in star, such as: I have this code so far: def draw_star(size,color): count = 0 ...

Building an array of tuples as elements?

I have x = np.arange(0, 4, 1) y = np.arange(0, 4, 1) and I want array([[(0,0), (0,1), (0,2), (0,3)], [(1,...

Are for-loops in pandas really bad? When should I care??

Are for loops really "bad"? If not, in what situation(s) would they be better than using a more conventional "vector...

How to turn Numpy array to set efficiently??

I used: df['ids'] = df['ids'].values.astype(set) to turn lists into sets, but the output was a list not a set: ...

Difference between list(dict) and dict.keys()??

Say I have a dict: foo = {'a': 1} Both list(foo) and foo.keys() return the same thing. What's the difference betw...