Skip to content

Python package names collision

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…