Skip to content

Tag: python

How to create a delayed queue in RabbitMQ?

What is the easiest way to create a delay (or parking) queue with Python, Pika and RabbitMQ? I have seen an similar questions, but none for Python. I find this an useful idea when designing applications, as it allows us to throttle messages that needs to be re-queued again. There are always the possibility th…

Puzzled on the ndim from Numpy

Above is my code. the output is: I have checked the page from [here] (Link) I expected a.dim = 2 or 3, but it is 4. Why? Could you give me some hints? Thanks Answer The tuple you give to zeros and other similar functions gives the ‘shape’ of the array (and is available for any array as a.shape). T…

Relative imports in Python 3

I want to import a function from another file in the same directory. Usually, one of the following works: …but the other one gives me one of these errors: Why is this? Answer unfortunately, this module needs to be inside the package, and it also needs to be runnable as a script, sometimes. Any idea how …

Writing a pandas DataFrame to CSV file

I have a dataframe in pandas which I would like to write to a CSV file. I am doing this using: And getting the following error: Is there any way to get around this easily (i.e. I have unicode characters in my data frame)? And is there a way to write to a tab delimited file instead of a CSV

Python vs C: different outputs

I have a small program that converts a base 10 number into a kind of a base 36 number. Here’s the Python code, and it works as expected. The output is “4 45 46” correctly represents 0, and “4 9 24” correctly represents 200. But the issue is, it stops working after I convert it to…

How to resize window in opencv2 python

I am using opencv 2 with a webcam. I can get the video stream and process it, but I can’t seem to figure out a way to resize the display window. I have some video images stacked horizontally, but the image dimension is very small that it’s difficult to see things. My code is pretty simple, and alo…