I have a following project structure: when I run python program_name from top level directory I get an error. It appears, that some of mine dependencies import the package with the same name as mine. Namely I import numpy in __main__.py and, somewhere deep inside, it has import package_name line. So instead o…
Index Pandas Dataframe mixing row number and column name
Coming from R and finding the index rules for pandas dataframes to be not easy to use. I have a dataframe where I want to get the ith row and some columns by their names. I can clearly understand using either iloc or loc as shown below. Conceptually what I want is something like: Meaning the first row with th…
how rank is calculated in pandas
I confuse to understand rank of series. I know that rank is calculated from the highest value to lowest value in a series. If two numbers are equal, then pandas calculates the average of the numbers. In this example, the highest value is 7. why do we get rank 5.5 for number 7 and rank 1.5 for number 4 ?
mypy declares IO[bytes] incompatible with BinaryIO
Consider the following code: Running mypy v0.782 on the above code under Python 3.6.9 fails with the following error: However, I feel that this code should not be regarded as an error, as ZipFile.open() returns a binary filehandle, which TextIOWrapper accepts. Moreover, IO[bytes] and BinaryIO are (as far as I…
How to specify the color for a partial histogram patch
I would like to produce the following graph Note that one bar is partially blue and partially teal. This is what I’m trying to reproduce Rectangle(xy=(0.876747, 0), width=0.408487, height=0.206371, angle=0) is the Rectangle that needs to be partially colored. Rectangle(xy=(1.28523, 0), width=0.408487, h…
Why package is not updated even the lifecycle script has been executed successfully in SageMaker?
I wanted to update pandas version in ‘conda-python3’ in SageMaker, I’ve followed the steps in this page, and linked the new configuration to my instance, CloudWatch log shows me the script has been executed successfully, but when I restart my instance and print out the panda version, it̵…
OSError: [WinError 193] %1 is not a valid Win32 application while reading custom DLL in python with CTypes
I am trying to write code that wraps a C library in python. I am planning on using CTypes to do it and I used visual studio to compile my DLL. I started with a simple function and I added the following in a header within Visual Studio that was then built to a DLL My python wrapper is the
Django items = order.orderitem_set.all() returning empty value for quantity
When I try and put the {{ item.product.quantity }} in it returns an empty value. The quantity value is filled in in the database. I can’t seem t pinpoint the problem. I have tried printing the quantity value but got the same results. cart.html views.py models.py If I do print(items) the result would be:…
Failing to install psycopg2-binary on new docker container
I have encountered a problem while trying to run my django project on a new Docker container. It is my first time using Docker and I can’t seem to find a good way to run a django project on it. Having tried multiple tutorials, I always get the error about psycopg2 not being installed. requirements.txt: …
ClientError: An error occurred (InternalFailure) when calling the Publish operation (reached max retries: 4)
I am simply trying to publish to an SNS topic using a lambda function. The function code as follows, with ARN being the actual SNS topic ARN: The function execution role as access to SNS. In fact I even gave SNS full access. But I keep getting the error: I do not find any access denied errors in cloudtrail ei…